Skip to content

Commit 27a72e5

Browse files
committed
2220
1 parent ee435c8 commit 27a72e5

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

spec/integration/map_reduce_spec.rb

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99

1010
let(:subscriber) { EventSubscriber.new }
1111

12+
let(:find_options) { {} }
13+
1214
let(:operation) do
13-
collection.find.map_reduce('function(){}', 'function(){}')
15+
collection.find({}, find_options).map_reduce('function(){}', 'function(){}')
1416
end
1517

1618
before do
@@ -23,12 +25,34 @@
2325
context 'read preference' do
2426
require_topology :sharded
2527

26-
let(:client) { authorized_client.with(read: {mode: :secondary_preferred }) }
28+
context 'specified on client' do
29+
let(:client) { authorized_client.with(read: {mode: :secondary_preferred }) }
2730

28-
it 'is sent' do
29-
operation.to_a
31+
it 'is sent' do
32+
operation.to_a
33+
34+
event.command['$readPreference'].should == {'mode' => 'secondaryPreferred'}
35+
end
36+
end
37+
38+
context 'specified on collection' do
39+
let(:collection) { client['mr_integration', read: {mode: :secondary_preferred }] }
40+
41+
it 'is sent' do
42+
operation.to_a
43+
44+
event.command['$readPreference'].should == {'mode' => 'secondaryPreferred'}
45+
end
46+
end
47+
48+
context 'specified on operation' do
49+
let(:find_options) { {read: {mode: :secondary_preferred }} }
50+
51+
it 'is sent' do
52+
operation.to_a
3053

31-
event.command['$readPreference'].should == {'mode' => 'secondaryPreferred'}
54+
event.command['$readPreference'].should == {'mode' => 'secondaryPreferred'}
55+
end
3256
end
3357
end
3458

0 commit comments

Comments
 (0)