Skip to content

Commit 0ba4583

Browse files
authored
Merge pull request #4543 from saghm/6.4.0-stable
6.4.0 stable
2 parents c73f53d + aeb80d7 commit 0ba4583

File tree

5 files changed

+40
-46
lines changed

5 files changed

+40
-46
lines changed

.travis.yml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,16 @@ before_install:
1313
- gem update --system
1414
- gem update bundler
1515

16-
matrix:
17-
fast_finish: true
18-
exclude:
19-
- rvm: ruby-head
20-
gemfile: gemfiles/rails_master.gemfile
21-
- rvm: jruby-9.1.15.0
22-
gemfile: gemfiles/rails_master.gemfile
23-
- rvm: jruby-9.1.15.0
24-
gemfile: gemfiles/driver_master.gemfile
25-
- rvm: jruby-9.1.15.0
26-
env: MONGODB=2.6.12
27-
- rvm: jruby-9.1.15.0
28-
env: MONGODB=3.4.10
29-
allow_failures:
30-
- rvm: ruby-head
31-
- gemfile: gemfiles/rails_master.gemfile
32-
3316
rvm:
34-
- 2.5
35-
- ruby-head
36-
- jruby-9.1.15.0
17+
- 2.4.1
3718

3819
gemfile:
3920
- Gemfile
40-
- gemfiles/driver_master.gemfile
41-
- gemfiles/rails_master.gemfile
4221

4322
env:
4423
global:
4524
- CI="travis"
46-
- JRUBY_OPTS="--server -J-Xms512m -J-Xmx1G"
47-
matrix:
48-
- MONGODB=2.6.12
49-
- MONGODB=3.4.10
50-
- MONGODB=3.6.2
25+
- MONGODB=3.4.17
5126

5227
before_script:
5328
- wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB}.tgz -O /tmp/mongodb.tgz

lib/mongoid/persistence_context.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def database_name
107107
#
108108
# @since 6.0.0
109109
def client
110+
client_options = send(:client_options)
111+
if client_options[:read].is_a?(Symbol)
112+
client_options = client_options.merge(read: {mode: client_options[:read]})
113+
end
110114
@client ||= (client = Clients.with_name(client_name)
111115
client = client.use(database_name) if database_name_option
112116
client.with(client_options))

spec/mongoid/clients/factory_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@
132132

133133
let(:config) do
134134
{
135-
default: { hosts: [ "127.0.0.1:27017" ], database: database_id },
136-
secondary: { uri: "mongodb://127.0.0.1:27017,127.0.0.1:27018/mongoid_test" }
135+
default: { hosts: [ "127.0.0.1:1234" ], database: database_id },
136+
secondary: { uri: "mongodb://127.0.0.1:1234,127.0.0.1:5678/mongoid_test" }
137137
}
138138
end
139139

@@ -162,7 +162,7 @@
162162
end
163163

164164
it "sets the cluster's seeds" do
165-
expect(seeds).to eq([ "127.0.0.1:27017", "127.0.0.1:27018" ])
165+
expect(seeds).to eq([ "127.0.0.1:1234", "127.0.0.1:5678" ])
166166
end
167167
end
168168
end

spec/mongoid/clients/options_spec.rb

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,40 @@
177177

178178
context 'when returning a criteria' do
179179

180-
let(:context_and_criteria) do
181-
collection = nil
182-
cxt = Band.with(read: :secondary) do |klass|
183-
collection = klass.all.collection
184-
klass.persistence_context
180+
shared_context 'applies secondary read preference' do
181+
182+
let(:context_and_criteria) do
183+
collection = nil
184+
cxt = Band.with(read_secondary_option) do |klass|
185+
collection = klass.all.collection
186+
klass.persistence_context
187+
end
188+
[ cxt, collection ]
185189
end
186-
[ cxt, collection ]
187-
end
188190

189-
let(:persistence_context) do
190-
context_and_criteria[0]
191+
let(:persistence_context) do
192+
context_and_criteria[0]
193+
end
194+
195+
let(:client) do
196+
context_and_criteria[1].client
197+
end
198+
199+
it 'applies the options to the criteria client' do
200+
expect(client.options['read']).to eq('mode' => :secondary)
201+
end
191202
end
192203

193-
let(:client) do
194-
context_and_criteria[1].client
204+
context 'read: :secondary shorthand' do
205+
let(:read_secondary_option) { {read: :secondary} }
206+
207+
it_behaves_like 'applies secondary read preference'
195208
end
196209

197-
it 'applies the options to the criteria client' do
198-
expect(client.options['read']).to eq(:secondary)
210+
context 'read: {mode: :secondary}' do
211+
let(:read_secondary_option) { {read: {mode: :secondary}} }
212+
213+
it_behaves_like 'applies secondary read preference'
199214
end
200215
end
201216

spec/mongoid/clients/sessions_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
end
1717

1818
let(:subscriber) do
19-
Mongoid::Clients.with_name(:other).instance_variable_get(:@monitoring).subscribers['Command'].find do |s|
19+
Mongoid::Clients.with_name(:other).send(:monitoring).subscribers['Command'].find do |s|
2020
s.is_a?(EventSubscriber)
2121
end
2222
end
2323

2424
let(:insert_events) do
25-
subscriber.started_events.select { |event| event.command_name == :insert }
25+
subscriber.started_events.select { |event| event.command_name == 'insert' }
2626
end
2727

2828
let(:update_events) do
29-
subscriber.started_events.select { |event| event.command_name == :update }
29+
subscriber.started_events.select { |event| event.command_name == 'update' }
3030
end
3131

3232
context 'when a session is used on a model class' do

0 commit comments

Comments
 (0)