Skip to content

Commit d2e3bcf

Browse files
committed
RUBY-1054 Explicitly test that client read pref is not used
1 parent 9b9b85a commit d2e3bcf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spec/mongo/database_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@
228228
end.to raise_error(Mongo::Error::NoServerAvailable)
229229
end
230230
end
231+
232+
context 'when there is a read preference set on the client' do
233+
234+
let(:database) do
235+
described_class.new(authorized_client.with(read: { mode: :secondary }), TEST_DB)
236+
end
237+
238+
it 'does not use the read preference' do
239+
expect(database.client.cluster).to receive(:next_primary).and_call_original
240+
database.command(ping: 1)
241+
end
242+
end
231243
end
232244

233245
describe '#drop' do

0 commit comments

Comments
 (0)