File tree Expand file tree Collapse file tree 2 files changed +53
-7
lines changed Expand file tree Collapse file tree 2 files changed +53
-7
lines changed Original file line number Diff line number Diff line change @@ -356,13 +356,6 @@ def initialize(addresses_or_uri, options = nil)
356
356
options = { }
357
357
end
358
358
359
- unless options [ :retry_reads ] == false
360
- options [ :retry_reads ] = true
361
- end
362
- unless options [ :retry_writes ] == false
363
- options [ :retry_writes ] = true
364
- end
365
-
366
359
if addresses_or_uri . is_a? ( ::String )
367
360
uri = URI . get ( addresses_or_uri , options )
368
361
addresses = uri . servers
@@ -379,6 +372,13 @@ def initialize(addresses_or_uri, options = nil)
379
372
addresses = addresses_or_uri
380
373
end
381
374
375
+ unless options [ :retry_reads ] == false
376
+ options [ :retry_reads ] = true
377
+ end
378
+ unless options [ :retry_writes ] == false
379
+ options [ :retry_writes ] = true
380
+ end
381
+
382
382
# Special handling for sdam_proc as it is only used during client
383
383
# construction
384
384
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