|
325 | 325 | end |
326 | 326 | end |
327 | 327 |
|
| 328 | + context 'when hidden is specified' do |
| 329 | + let(:index) { view.get('with_hidden_1') } |
| 330 | + |
| 331 | + context 'on server versions <= 3.2' do |
| 332 | + # DRIVERS-1220 Server versions 3.2 and older do not perform any option |
| 333 | + # checking on index creation. The server will allow the user to create |
| 334 | + # the index with the hidden option, but the server does not support this |
| 335 | + # option and will not use it. |
| 336 | + max_server_fcv '3.2' |
| 337 | + |
| 338 | + let!(:result) do |
| 339 | + view.create_many({ key: { with_hidden: 1 }, hidden: true }) |
| 340 | + end |
| 341 | + |
| 342 | + it 'returns ok' do |
| 343 | + expect(result).to be_successful |
| 344 | + end |
| 345 | + |
| 346 | + it 'creates an index' do |
| 347 | + expect(index).to_not be_nil |
| 348 | + end |
| 349 | + end |
| 350 | + |
| 351 | + context 'on server versions between 3.4 and 4.2' do |
| 352 | + max_server_fcv '4.2' |
| 353 | + min_server_fcv '3.4' |
| 354 | + |
| 355 | + it 'raises an exception' do |
| 356 | + expect do |
| 357 | + view.create_many({ key: { with_hidden: 1 }, hidden: true }) |
| 358 | + end.to raise_error(/The field 'hidden' is not valid for an index specification/) |
| 359 | + end |
| 360 | + end |
| 361 | + |
| 362 | + context 'on server versions >= 4.4' do |
| 363 | + min_server_fcv '4.4' |
| 364 | + |
| 365 | + context 'when hidden is true' do |
| 366 | + let!(:result) do |
| 367 | + view.create_many({ key: { with_hidden: 1 }, hidden: true }) |
| 368 | + end |
| 369 | + |
| 370 | + it 'returns ok' do |
| 371 | + expect(result).to be_successful |
| 372 | + end |
| 373 | + |
| 374 | + it 'creates an index' do |
| 375 | + expect(index).to_not be_nil |
| 376 | + end |
| 377 | + |
| 378 | + it 'applies the hidden option to the index' do |
| 379 | + expect(index['hidden']).to be true |
| 380 | + end |
| 381 | + end |
| 382 | + |
| 383 | + context 'when hidden is false' do |
| 384 | + let!(:result) do |
| 385 | + view.create_many({ key: { with_hidden: 1 }, hidden: false }) |
| 386 | + end |
| 387 | + |
| 388 | + it 'returns ok' do |
| 389 | + expect(result).to be_successful |
| 390 | + end |
| 391 | + |
| 392 | + it 'creates an index' do |
| 393 | + expect(index).to_not be_nil |
| 394 | + end |
| 395 | + |
| 396 | + it 'does not apply the hidden option to the index' do |
| 397 | + expect(index['hidden']).to be_nil |
| 398 | + end |
| 399 | + end |
| 400 | + end |
| 401 | + end |
| 402 | + |
328 | 403 | context 'when collation is specified' do |
329 | 404 | min_server_fcv '3.4' |
330 | 405 |
|
|
773 | 848 | end |
774 | 849 | end |
775 | 850 |
|
| 851 | + context 'when providing hidden option' do |
| 852 | + let(:index) { view.get('with_hidden_1') } |
| 853 | + |
| 854 | + context 'on server versions <= 3.2' do |
| 855 | + # DRIVERS-1220 Server versions 3.2 and older do not perform any option |
| 856 | + # checking on index creation. The server will allow the user to create |
| 857 | + # the index with the hidden option, but the server does not support this |
| 858 | + # option and will not use it. |
| 859 | + max_server_fcv '3.2' |
| 860 | + |
| 861 | + let!(:result) do |
| 862 | + view.create_one({ 'with_hidden' => 1 }, { hidden: true }) |
| 863 | + end |
| 864 | + |
| 865 | + it 'returns ok' do |
| 866 | + expect(result).to be_successful |
| 867 | + end |
| 868 | + |
| 869 | + it 'creates an index' do |
| 870 | + expect(index).to_not be_nil |
| 871 | + end |
| 872 | + end |
| 873 | + |
| 874 | + context 'on server versions between 3.4 and 4.2' do |
| 875 | + max_server_fcv '4.2' |
| 876 | + min_server_fcv '3.4' |
| 877 | + |
| 878 | + it 'raises an exception' do |
| 879 | + expect do |
| 880 | + view.create_one({ 'with_hidden' => 1 }, { hidden: true }) |
| 881 | + end.to raise_error(/The field 'hidden' is not valid for an index specification/) |
| 882 | + end |
| 883 | + end |
| 884 | + |
| 885 | + context 'on server versions >= 4.4' do |
| 886 | + min_server_fcv '4.4' |
| 887 | + |
| 888 | + context 'when hidden is true' do |
| 889 | + let!(:result) { view.create_one({ 'with_hidden' => 1 }, { hidden: true }) } |
| 890 | + |
| 891 | + it 'returns ok' do |
| 892 | + expect(result).to be_successful |
| 893 | + end |
| 894 | + |
| 895 | + it 'creates an index' do |
| 896 | + expect(index).to_not be_nil |
| 897 | + end |
| 898 | + |
| 899 | + it 'applies the hidden option to the index' do |
| 900 | + expect(index['hidden']).to be true |
| 901 | + end |
| 902 | + end |
| 903 | + |
| 904 | + context 'when hidden is false' do |
| 905 | + let!(:result) { view.create_one({ 'with_hidden' => 1 }, { hidden: false }) } |
| 906 | + |
| 907 | + it 'returns ok' do |
| 908 | + expect(result).to be_successful |
| 909 | + end |
| 910 | + |
| 911 | + it 'creates an index' do |
| 912 | + expect(index).to_not be_nil |
| 913 | + end |
| 914 | + |
| 915 | + it 'does not apply the hidden option to the index' do |
| 916 | + expect(index['hidden']).to be_nil |
| 917 | + end |
| 918 | + end |
| 919 | + end |
| 920 | + end |
| 921 | + |
776 | 922 | context 'when providing commit_quorum option' do |
777 | 923 | require_topology :replica_set, :sharded |
778 | 924 | context 'on server versions >= 4.4' do |
|
0 commit comments