File tree Expand file tree Collapse file tree 2 files changed +56
-6
lines changed Expand file tree Collapse file tree 2 files changed +56
-6
lines changed Original file line number Diff line number Diff line change @@ -346,21 +346,25 @@ def initialize(addresses_or_uri, options = nil)
346
346
else
347
347
options = { }
348
348
end
349
- unless options [ :retry_reads ] == false
350
- options [ :retry_reads ] = true
351
- end
352
- unless options [ :retry_writes ] == false
353
- options [ :retry_writes ] = true
354
- end
349
+
355
350
Lint . validate_underscore_read_preference ( options [ :read ] )
356
351
Lint . validate_read_concern_option ( options [ :read_concern ] )
352
+
357
353
if addresses_or_uri . is_a? ( ::String )
358
354
uri = URI . get ( addresses_or_uri , options )
359
355
addresses = uri . servers
360
356
options = uri . client_options . merge ( options )
361
357
else
362
358
addresses = addresses_or_uri
363
359
end
360
+
361
+ unless options [ :retry_reads ] == false
362
+ options [ :retry_reads ] = true
363
+ end
364
+ unless options [ :retry_writes ] == false
365
+ options [ :retry_writes ] = true
366
+ end
367
+
364
368
# Special handling for sdam_proc as it is only used during client
365
369
# construction
366
370
sdam_proc = options . delete ( :sdam_proc )
Original file line number Diff line number Diff line change 742
742
end
743
743
end
744
744
end
745
+
746
+ context 'when retryReads URI option is given' do
747
+
748
+ context 'it is false' do
749
+ let! ( :uri ) do
750
+ 'mongodb://127.0.0.1:27017/testdb?retryReads=false'
751
+ end
752
+
753
+ it 'sets the option on the client' do
754
+ expect ( client . options [ :retry_reads ] ) . to be false
755
+ end
756
+ end
757
+
758
+ context 'it is true' do
759
+ let! ( :uri ) do
760
+ 'mongodb://127.0.0.1:27017/testdb?retryReads=true'
761
+ end
762
+
763
+ it 'sets the option on the client' do
764
+ expect ( client . options [ :retry_reads ] ) . to be true
765
+ end
766
+ end
767
+ end
768
+
769
+ context 'when retryWrites URI option is given' do
770
+
771
+ context 'it is false' do
772
+ let! ( :uri ) do
773
+ 'mongodb://127.0.0.1:27017/testdb?retryWrites=false'
774
+ end
775
+
776
+ it 'sets the option on the client' do
777
+ expect ( client . options [ :retry_writes ] ) . to be false
778
+ end
779
+ end
780
+
781
+ context 'it is true' do
782
+ let! ( :uri ) do
783
+ 'mongodb://127.0.0.1:27017/testdb?retryWrites=true'
784
+ end
785
+
786
+ it 'sets the option on the client' do
787
+ expect ( client . options [ :retry_writes ] ) . to be true
788
+ end
789
+ end
790
+ end
745
791
end
746
792
747
793
context 'when options are provided not in the string' do
You can’t perform that action at this time.
0 commit comments