mongoid 7.1.0.rc0 → 7.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG.md +6 -6
  5. data/LICENSE +1 -1
  6. data/README.md +5 -5
  7. data/Rakefile +14 -0
  8. data/lib/config/locales/en.yml +5 -5
  9. data/lib/mongoid.rb +3 -2
  10. data/lib/mongoid/association/accessors.rb +37 -2
  11. data/lib/mongoid/association/embedded/embeds_many.rb +2 -1
  12. data/lib/mongoid/association/embedded/embeds_one.rb +2 -1
  13. data/lib/mongoid/association/many.rb +3 -2
  14. data/lib/mongoid/association/proxy.rb +6 -4
  15. data/lib/mongoid/association/referenced/belongs_to/binding.rb +1 -1
  16. data/lib/mongoid/association/referenced/belongs_to/eager.rb +38 -2
  17. data/lib/mongoid/association/referenced/eager.rb +29 -9
  18. data/lib/mongoid/association/referenced/has_many/enumerable.rb +2 -22
  19. data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -2
  20. data/lib/mongoid/atomic.rb +13 -3
  21. data/lib/mongoid/attributes.rb +28 -20
  22. data/lib/mongoid/clients/factory.rb +2 -2
  23. data/lib/mongoid/clients/options.rb +8 -8
  24. data/lib/mongoid/clients/sessions.rb +20 -4
  25. data/lib/mongoid/clients/storage_options.rb +5 -5
  26. data/lib/mongoid/config.rb +42 -12
  27. data/lib/mongoid/config/options.rb +5 -2
  28. data/lib/mongoid/contextual.rb +5 -4
  29. data/lib/mongoid/contextual/geo_near.rb +3 -2
  30. data/lib/mongoid/contextual/map_reduce.rb +3 -2
  31. data/lib/mongoid/contextual/mongo.rb +2 -1
  32. data/lib/mongoid/criteria.rb +23 -4
  33. data/lib/mongoid/criteria/modifiable.rb +2 -1
  34. data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -1
  35. data/lib/mongoid/criteria/queryable/extensions/regexp.rb +6 -6
  36. data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +12 -0
  37. data/lib/mongoid/criteria/queryable/mergeable.rb +75 -8
  38. data/lib/mongoid/criteria/queryable/pipeline.rb +3 -2
  39. data/lib/mongoid/criteria/queryable/selectable.rb +120 -13
  40. data/lib/mongoid/criteria/queryable/storable.rb +104 -99
  41. data/lib/mongoid/errors/eager_load.rb +2 -0
  42. data/lib/mongoid/errors/no_client_config.rb +2 -2
  43. data/lib/mongoid/errors/no_default_client.rb +1 -1
  44. data/lib/mongoid/extensions/hash.rb +4 -2
  45. data/lib/mongoid/extensions/regexp.rb +1 -1
  46. data/lib/mongoid/fields.rb +2 -1
  47. data/lib/mongoid/fields/standard.rb +2 -1
  48. data/lib/mongoid/fields/validators/macro.rb +4 -1
  49. data/lib/mongoid/findable.rb +5 -4
  50. data/lib/mongoid/interceptable.rb +5 -1
  51. data/lib/mongoid/matchable/regexp.rb +2 -2
  52. data/lib/mongoid/persistable/pushable.rb +11 -2
  53. data/lib/mongoid/persistence_context.rb +6 -6
  54. data/lib/mongoid/query_cache.rb +61 -18
  55. data/lib/mongoid/railties/database.rake +7 -0
  56. data/lib/mongoid/serializable.rb +10 -2
  57. data/lib/mongoid/shardable.rb +56 -4
  58. data/lib/mongoid/tasks/database.rake +10 -5
  59. data/lib/mongoid/tasks/database.rb +83 -0
  60. data/lib/mongoid/timestamps/timeless.rb +3 -1
  61. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  62. data/lib/mongoid/version.rb +1 -1
  63. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +32 -23
  64. data/lib/rails/generators/mongoid/model/templates/model.rb.tt +1 -1
  65. data/spec/app/models/coding.rb +4 -0
  66. data/spec/app/models/coding/pull_request.rb +12 -0
  67. data/spec/app/models/delegating_patient.rb +16 -0
  68. data/spec/app/models/passport.rb +1 -0
  69. data/spec/app/models/phone.rb +1 -0
  70. data/spec/app/models/publication.rb +5 -0
  71. data/spec/app/models/publication/encyclopedia.rb +12 -0
  72. data/spec/app/models/publication/review.rb +14 -0
  73. data/spec/integration/app_spec.rb +254 -0
  74. data/spec/integration/associations/embedded_spec.rb +54 -0
  75. data/spec/integration/associations/has_many_spec.rb +34 -0
  76. data/spec/integration/associations/has_one_spec.rb +34 -0
  77. data/spec/integration/bson_regexp_raw_spec.rb +20 -0
  78. data/spec/integration/criteria/date_field_spec.rb +41 -0
  79. data/spec/integration/criteria/logical_spec.rb +13 -0
  80. data/spec/integration/document_spec.rb +22 -0
  81. data/spec/integration/shardable_spec.rb +149 -0
  82. data/spec/lite_spec_helper.rb +15 -4
  83. data/spec/mongoid/association/accessors_spec.rb +238 -63
  84. data/spec/mongoid/association/embedded/embeds_many_models.rb +19 -0
  85. data/spec/mongoid/association/embedded/embeds_many_spec.rb +10 -0
  86. data/spec/mongoid/association/embedded/embeds_one_spec.rb +0 -2
  87. data/spec/mongoid/association/referenced/belongs_to/eager_spec.rb +193 -10
  88. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +140 -1
  89. data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +146 -68
  90. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +2 -1
  91. data/spec/mongoid/attributes_spec.rb +19 -7
  92. data/spec/mongoid/changeable_spec.rb +23 -0
  93. data/spec/mongoid/clients/factory_spec.rb +8 -8
  94. data/spec/mongoid/clients/options_spec.rb +11 -11
  95. data/spec/mongoid/clients/sessions_spec.rb +8 -4
  96. data/spec/mongoid/clients/transactions_spec.rb +20 -8
  97. data/spec/mongoid/clients_spec.rb +2 -2
  98. data/spec/mongoid/contextual/atomic_spec.rb +22 -11
  99. data/spec/mongoid/contextual/geo_near_spec.rb +11 -2
  100. data/spec/mongoid/contextual/map_reduce_spec.rb +20 -5
  101. data/spec/mongoid/contextual/mongo_spec.rb +76 -53
  102. data/spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb +1 -1
  103. data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +7 -7
  104. data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +1 -1
  105. data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +19 -7
  106. data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +28 -1
  107. data/spec/mongoid/criteria/queryable/mergeable_spec.rb +45 -12
  108. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +1051 -392
  109. data/spec/mongoid/criteria/queryable/selectable_spec.rb +52 -0
  110. data/spec/mongoid/criteria/queryable/storable_spec.rb +80 -2
  111. data/spec/mongoid/criteria_spec.rb +36 -2
  112. data/spec/mongoid/document_fields_spec.rb +29 -0
  113. data/spec/mongoid/document_persistence_context_spec.rb +33 -0
  114. data/spec/mongoid/errors/no_client_config_spec.rb +2 -2
  115. data/spec/mongoid/errors/no_client_database_spec.rb +3 -3
  116. data/spec/mongoid/errors/no_client_hosts_spec.rb +3 -3
  117. data/spec/mongoid/fields_spec.rb +24 -1
  118. data/spec/mongoid/indexable_spec.rb +6 -4
  119. data/spec/mongoid/interceptable_spec.rb +62 -0
  120. data/spec/mongoid/interceptable_spec_models.rb +76 -0
  121. data/spec/mongoid/matchable/default_spec.rb +1 -1
  122. data/spec/mongoid/matchable/regexp_spec.rb +2 -2
  123. data/spec/mongoid/matchable_spec.rb +2 -2
  124. data/spec/mongoid/persistable/pushable_spec.rb +55 -1
  125. data/spec/mongoid/query_cache_spec.rb +77 -9
  126. data/spec/mongoid/relations/proxy_spec.rb +1 -1
  127. data/spec/mongoid/scopable_spec.rb +2 -1
  128. data/spec/mongoid/serializable_spec.rb +129 -18
  129. data/spec/mongoid/shardable_models.rb +61 -0
  130. data/spec/mongoid/shardable_spec.rb +69 -16
  131. data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
  132. data/spec/mongoid/tasks/database_spec.rb +1 -1
  133. data/spec/spec_helper.rb +2 -31
  134. data/spec/support/child_process_helper.rb +76 -0
  135. data/spec/support/cluster_config.rb +3 -3
  136. data/spec/support/constraints.rb +26 -10
  137. data/spec/support/expectations.rb +3 -1
  138. data/spec/support/helpers.rb +11 -0
  139. data/spec/support/lite_constraints.rb +22 -0
  140. data/spec/support/session_registry.rb +50 -0
  141. data/spec/support/spec_config.rb +12 -4
  142. metadata +518 -480
  143. metadata.gz.sig +0 -0
@@ -2907,7 +2907,8 @@ describe Mongoid::Association::Referenced::HasMany::Proxy do
2907
2907
  expect(posts).to eq([ post_one ])
2908
2908
  end
2909
2909
 
2910
- context 'when providing a collation', if: collation_supported? do
2910
+ context 'when providing a collation' do
2911
+ min_server_version '3.4'
2911
2912
 
2912
2913
  let(:posts) do
2913
2914
  person.posts.where(title: "FIRST").collation(locale: 'en_US', strength: 2)
@@ -1349,10 +1349,16 @@ describe Mongoid::Attributes do
1349
1349
  context "when attribute is a Hash" do
1350
1350
  let(:person) { Person.new map: { somekey: "somevalue" } }
1351
1351
 
1352
- it "raises an error when try to set an invalid value" do
1353
- expect {
1352
+ it "raises an error when trying to set a value of invalid type - array" do
1353
+ expect do
1354
1354
  person.map = []
1355
- }.to raise_error(Mongoid::Errors::InvalidValue)
1355
+ end.to raise_error(Mongoid::Errors::InvalidValue, /Value of type Array cannot be written to a field of type Hash/)
1356
+ end
1357
+
1358
+ it "raises an error when trying to set a value of invalid type - boolean" do
1359
+ expect do
1360
+ person.map = false
1361
+ end.to raise_error(Mongoid::Errors::InvalidValue, /Value of type FalseClass cannot be written to a field of type Hash/)
1356
1362
  end
1357
1363
 
1358
1364
  it "can set a Hash value" do
@@ -1367,10 +1373,16 @@ describe Mongoid::Attributes do
1367
1373
  expect(person.aliases).to eq([ :alias_1 ])
1368
1374
  end
1369
1375
 
1370
- it "raises an error when try to set an invalid value" do
1371
- expect {
1376
+ it "raises an error when trying to set a value of invalid type - hash" do
1377
+ expect do
1372
1378
  person.aliases = {}
1373
- }.to raise_error(Mongoid::Errors::InvalidValue)
1379
+ end.to raise_error(Mongoid::Errors::InvalidValue, /Value of type Hash cannot be written to a field of type Array/)
1380
+ end
1381
+
1382
+ it "raises an error when trying to set a value of invalid type - boolean" do
1383
+ expect do
1384
+ person.aliases = false
1385
+ end.to raise_error(Mongoid::Errors::InvalidValue, /Value of type FalseClass cannot be written to a field of type Array/)
1374
1386
  end
1375
1387
  end
1376
1388
 
@@ -1425,7 +1437,7 @@ describe Mongoid::Attributes do
1425
1437
  end
1426
1438
 
1427
1439
  describe "#typed_attributes" do
1428
-
1440
+
1429
1441
  let(:date_time) do
1430
1442
  DateTime.current
1431
1443
  end
@@ -949,6 +949,29 @@ describe Mongoid::Changeable do
949
949
  end
950
950
  end
951
951
 
952
+ context 'when habtm association changes' do
953
+
954
+ let(:person) do
955
+ Person.create!(title: "Grand Poobah")
956
+ end
957
+
958
+ let(:user_account) do
959
+ UserAccount.create!
960
+ end
961
+
962
+ before do
963
+ person.user_accounts << user_account
964
+ end
965
+
966
+ it 'returns a hash of changes' do
967
+ pending 'https://jira.mongodb.org/browse/MONGOID-4843'
968
+
969
+ person.changes.should == {
970
+ user_account_ids: [[], [user_account.id]]
971
+ }
972
+ end
973
+ end
974
+
952
975
  context "when the document has not changed" do
953
976
 
954
977
  let(:acolyte) do
@@ -41,7 +41,7 @@ describe Mongoid::Clients::Factory do
41
41
  let(:config) do
42
42
  {
43
43
  default: { hosts: SpecConfig.instance.addresses, database: database_id },
44
- secondary: { hosts: SpecConfig.instance.addresses, database: database_id }
44
+ analytics: { hosts: SpecConfig.instance.addresses, database: database_id }
45
45
  }
46
46
  end
47
47
 
@@ -54,7 +54,7 @@ describe Mongoid::Clients::Factory do
54
54
  end
55
55
 
56
56
  let(:client) do
57
- described_class.create(:secondary)
57
+ described_class.create(:analytics)
58
58
  end
59
59
 
60
60
  let(:cluster) do
@@ -81,7 +81,7 @@ describe Mongoid::Clients::Factory do
81
81
  let(:config) do
82
82
  {
83
83
  default: { hosts: [ "127.0.0.1" ], database: database_id },
84
- secondary: { hosts: [ "127.0.0.1" ], database: database_id }
84
+ analytics: { hosts: [ "127.0.0.1" ], database: database_id }
85
85
  }
86
86
  end
87
87
 
@@ -94,7 +94,7 @@ describe Mongoid::Clients::Factory do
94
94
  end
95
95
 
96
96
  let(:client) do
97
- described_class.create(:secondary)
97
+ described_class.create(:analytics)
98
98
  end
99
99
 
100
100
  let(:default) do
@@ -125,7 +125,7 @@ describe Mongoid::Clients::Factory do
125
125
  let(:config) do
126
126
  {
127
127
  default: { hosts: [ "127.0.0.1:27017" ], database: database_id },
128
- secondary: { uri: "mongodb://127.0.0.1:27017/mongoid_test" }
128
+ analytics: { uri: "mongodb://127.0.0.1:27017/mongoid_test" }
129
129
  }
130
130
  end
131
131
 
@@ -138,7 +138,7 @@ describe Mongoid::Clients::Factory do
138
138
  end
139
139
 
140
140
  let(:client) do
141
- described_class.create(:secondary)
141
+ described_class.create(:analytics)
142
142
  end
143
143
 
144
144
  let(:cluster) do
@@ -163,7 +163,7 @@ describe Mongoid::Clients::Factory do
163
163
  let(:config) do
164
164
  {
165
165
  default: { hosts: [ "127.0.0.1:1234" ], database: database_id, server_selection_timeout: 1 },
166
- secondary: { uri: "mongodb://127.0.0.1:1234,127.0.0.1:5678/mongoid_test?serverSelectionTimeoutMS=1000" }
166
+ analytics: { uri: "mongodb://127.0.0.1:1234,127.0.0.1:5678/mongoid_test?serverSelectionTimeoutMS=1000" }
167
167
  }
168
168
  end
169
169
 
@@ -176,7 +176,7 @@ describe Mongoid::Clients::Factory do
176
176
  end
177
177
 
178
178
  let(:client) do
179
- described_class.create(:secondary)
179
+ described_class.create(:analytics)
180
180
  end
181
181
 
182
182
  let(:cluster) do
@@ -14,7 +14,7 @@ describe Mongoid::Clients::Options, retry: 3 do
14
14
  Mongoid::Clients.clients.clear
15
15
  end
16
16
 
17
- describe '#with', if: non_legacy_server? do
17
+ describe '#with' do
18
18
 
19
19
  context 'when passing some options' do
20
20
 
@@ -151,7 +151,7 @@ describe Mongoid::Clients::Options, retry: 3 do
151
151
  let(:config) do
152
152
  {
153
153
  default: { hosts: SpecConfig.instance.addresses, database: database_id },
154
- secondary: { uri: "mongodb://#{SpecConfig.instance.addresses.first}/secondary-db?connectTimeoutMS=3000" }
154
+ analytics: { uri: "mongodb://#{SpecConfig.instance.addresses.first}/analytics-db?connectTimeoutMS=3000" }
155
155
  }
156
156
  end
157
157
 
@@ -164,14 +164,14 @@ describe Mongoid::Clients::Options, retry: 3 do
164
164
  end
165
165
 
166
166
  let(:persistence_context) do
167
- Minim.with(client: :secondary) do |klass|
167
+ Minim.with(client: :analytics) do |klass|
168
168
  klass.persistence_context
169
169
  end
170
170
  end
171
171
 
172
172
  it 'uses the database specified in the uri' do
173
- expect(persistence_context.database_name).to eq('secondary-db')
174
- expect(persistence_context.client.database.name).to eq('secondary-db')
173
+ expect(persistence_context.database_name).to eq('analytics-db')
174
+ expect(persistence_context.client.database.name).to eq('analytics-db')
175
175
  end
176
176
 
177
177
  it 'uses the options specified in the uri' do
@@ -291,7 +291,7 @@ describe Mongoid::Clients::Options, retry: 3 do
291
291
  end
292
292
  end
293
293
 
294
- describe '.with', if: non_legacy_server? do
294
+ describe '.with' do
295
295
 
296
296
  context 'when passing some options' do
297
297
 
@@ -344,8 +344,8 @@ describe Mongoid::Clients::Options, retry: 3 do
344
344
  let(:config) do
345
345
  {
346
346
  default: { hosts: SpecConfig.instance.addresses, database: database_id },
347
- secondary: {
348
- uri: "mongodb://#{SpecConfig.instance.addresses.first}/secondary-db",
347
+ analytics: {
348
+ uri: "mongodb://#{SpecConfig.instance.addresses.first}/analytics-db",
349
349
  options: {
350
350
  server_selection_timeout: 0.5,
351
351
  },
@@ -358,14 +358,14 @@ describe Mongoid::Clients::Options, retry: 3 do
358
358
  end
359
359
 
360
360
  let(:persistence_context) do
361
- test_model.with(client: :secondary) do |object|
361
+ test_model.with(client: :analytics) do |object|
362
362
  object.persistence_context
363
363
  end
364
364
  end
365
365
 
366
366
  it 'uses the database specified in the uri' do
367
- expect(persistence_context.database_name).to eq('secondary-db')
368
- expect(persistence_context.client.database.name).to eq('secondary-db')
367
+ expect(persistence_context.database_name).to eq('analytics-db')
368
+ expect(persistence_context.client.database.name).to eq('analytics-db')
369
369
  end
370
370
  end
371
371
 
@@ -43,7 +43,8 @@ describe Mongoid::Clients::Sessions do
43
43
 
44
44
  context 'when a session is used on a model class' do
45
45
 
46
- context 'when sessions are supported', if: sessions_supported? do
46
+ context 'when sessions are supported' do
47
+ min_server_version '3.6'
47
48
 
48
49
  around do |example|
49
50
  Mongoid::Clients.with_name(:other).database.collections.each(&:drop)
@@ -172,7 +173,8 @@ describe Mongoid::Clients::Sessions do
172
173
  end
173
174
  end
174
175
 
175
- context 'when sessions are not supported', unless: sessions_supported? do
176
+ context 'when sessions are not supported' do
177
+ max_server_version '3.4'
176
178
 
177
179
  let!(:error) do
178
180
  e = nil
@@ -199,7 +201,8 @@ describe Mongoid::Clients::Sessions do
199
201
  end
200
202
  end
201
203
 
202
- context 'when sessions are supported', if: sessions_supported? do
204
+ context 'when sessions are supported' do
205
+ min_server_version '3.6'
203
206
 
204
207
  around do |example|
205
208
  Mongoid::Clients.with_name(:other).database.collections.each(&:drop)
@@ -316,7 +319,8 @@ describe Mongoid::Clients::Sessions do
316
319
  end
317
320
  end
318
321
 
319
- context 'when sessions are not supported', unless: sessions_supported? do
322
+ context 'when sessions are not supported' do
323
+ max_server_version '3.4'
320
324
 
321
325
  let!(:error) do
322
326
  e = nil
@@ -55,7 +55,8 @@ describe Mongoid::Clients::Sessions do
55
55
 
56
56
  context 'when a transaction is used on a model class' do
57
57
 
58
- context 'when transactions are supported', if: testing_transactions? do
58
+ context 'when transactions are supported' do
59
+ require_transaction_support
59
60
 
60
61
  around do |example|
61
62
  Mongoid::Clients.with_name(:other).database.collections.each(&:drop)
@@ -191,7 +192,10 @@ describe Mongoid::Clients::Sessions do
191
192
  end
192
193
  end
193
194
 
194
- context 'when sessions are supported but transactions are not', if: sessions_supported? && !testing_transactions? do
195
+ context 'when sessions are supported but transactions are not' do
196
+ min_server_version '3.6'
197
+ # Could also test 4.0 in sharded cluster
198
+ max_server_version '3.6'
195
199
 
196
200
  let!(:error) do
197
201
  e = nil
@@ -222,7 +226,8 @@ describe Mongoid::Clients::Sessions do
222
226
  end
223
227
  end
224
228
 
225
- context 'when transactions are supported', if: testing_transactions? do
229
+ context 'when transactions are supported' do
230
+ require_transaction_support
226
231
 
227
232
  around do |example|
228
233
  Mongoid::Clients.with_name(:other).database.collections.each(&:drop)
@@ -345,16 +350,23 @@ describe Mongoid::Clients::Sessions do
345
350
  end
346
351
  end
347
352
 
348
- context 'when sessions are supported but transactions are not', if: sessions_supported? && !testing_transactions? do
353
+ context 'when sessions are supported but transactions are not' do
354
+ min_server_version '3.6'
355
+ # Could also test 4.0 in sharded cluster
356
+ max_server_version '3.6'
349
357
 
350
358
  around do |example|
351
359
  Mongoid::Clients.with_name(:other).database.collections.each(&:drop)
352
360
  Mongoid::Clients.with_name(:other).command(create: :people)
353
- subscriber.clear_events!
354
- person.with(client: :other) do
355
- example.run
361
+
362
+ begin
363
+ subscriber.clear_events!
364
+ person.with(client: :other) do
365
+ example.run
366
+ end
367
+ ensure
368
+ Mongoid::Clients.with_name(:other).database.collections.each(&:drop)
356
369
  end
357
- Mongoid::Clients.with_name(:other).database.collections.each(&:drop)
358
370
  end
359
371
 
360
372
  let!(:error) do
@@ -728,7 +728,7 @@ describe Mongoid::Clients do
728
728
  end
729
729
  end
730
730
 
731
- describe ".store_in", if: non_legacy_server? do
731
+ describe ".store_in" do
732
732
 
733
733
  context "when provided a non hash" do
734
734
 
@@ -765,7 +765,7 @@ describe Mongoid::Clients do
765
765
  end
766
766
  end
767
767
 
768
- describe ".with", if: non_legacy_server? do
768
+ describe ".with" do
769
769
 
770
770
  context "when changing write concern options" do
771
771
 
@@ -77,7 +77,8 @@ describe Mongoid::Contextual::Atomic do
77
77
  end
78
78
  end
79
79
 
80
- context 'when the criteria has a collation', if: collation_supported? do
80
+ context 'when the criteria has a collation' do
81
+ min_server_version '3.4'
81
82
 
82
83
  let(:criteria) do
83
84
  Band.where(members: [ "DAVE" ]).collation(locale: 'en_US', strength: 2)
@@ -173,7 +174,8 @@ describe Mongoid::Contextual::Atomic do
173
174
  end
174
175
  end
175
176
 
176
- context 'when the criteria has a collation', if: collation_supported? do
177
+ context 'when the criteria has a collation' do
178
+ min_server_version '3.4'
177
179
 
178
180
  let(:criteria) do
179
181
  Band.where(members: [ "DAVE" ]).collation(locale: 'en_US', strength: 2)
@@ -244,7 +246,8 @@ describe Mongoid::Contextual::Atomic do
244
246
  end
245
247
  end
246
248
 
247
- context 'when the criteria has a collation', if: collation_supported? do
249
+ context 'when the criteria has a collation' do
250
+ min_server_version '3.4'
248
251
 
249
252
  let!(:depeche_mode) do
250
253
  Band.create(members: [ "Dave" ], likes: 60)
@@ -323,7 +326,8 @@ describe Mongoid::Contextual::Atomic do
323
326
  end
324
327
  end
325
328
 
326
- context 'when the criteria has a collation', if: collation_supported? do
329
+ context 'when the criteria has a collation' do
330
+ min_server_version '3.4'
327
331
 
328
332
  let!(:depeche_mode) do
329
333
  Band.create(members: [ "Dave" ])
@@ -395,7 +399,8 @@ describe Mongoid::Contextual::Atomic do
395
399
  end
396
400
  end
397
401
 
398
- context 'when the criteria has a collation', if: collation_supported? do
402
+ context 'when the criteria has a collation' do
403
+ min_server_version '3.4'
399
404
 
400
405
  let!(:depeche_mode) do
401
406
  Band.create(members: [ "Dave" ])
@@ -449,7 +454,8 @@ describe Mongoid::Contextual::Atomic do
449
454
  expect(smiths.reload.members).to be_nil
450
455
  end
451
456
 
452
- context 'when the criteria has a collation', if: collation_supported? do
457
+ context 'when the criteria has a collation' do
458
+ min_server_version '3.4'
453
459
 
454
460
  let!(:depeche_mode) do
455
461
  Band.create(members: [ "Dave" ])
@@ -506,7 +512,8 @@ describe Mongoid::Contextual::Atomic do
506
512
  end
507
513
  end
508
514
 
509
- context 'when the criteria has a collation', if: collation_supported? do
515
+ context 'when the criteria has a collation' do
516
+ min_server_version '3.4'
510
517
 
511
518
  let!(:depeche_mode) do
512
519
  Band.create(members: [ "Dave", "Alan", "Fletch" ])
@@ -563,7 +570,8 @@ describe Mongoid::Contextual::Atomic do
563
570
  end
564
571
  end
565
572
 
566
- context 'when the criteria has a collation', if: collation_supported? do
573
+ context 'when the criteria has a collation' do
574
+ min_server_version '3.4'
567
575
 
568
576
  let!(:depeche_mode) do
569
577
  Band.create(members: [ "Dave" ])
@@ -628,7 +636,8 @@ describe Mongoid::Contextual::Atomic do
628
636
  end
629
637
  end
630
638
 
631
- context 'when the criteria has a collation', if: collation_supported? do
639
+ context 'when the criteria has a collation' do
640
+ min_server_version '3.4'
632
641
 
633
642
  let!(:depeche_mode) do
634
643
  Band.create(members: [ "Dave" ])
@@ -689,7 +698,8 @@ describe Mongoid::Contextual::Atomic do
689
698
  end
690
699
  end
691
700
 
692
- context 'when the criteria has a collation', if: collation_supported? do
701
+ context 'when the criteria has a collation' do
702
+ min_server_version '3.4'
693
703
 
694
704
  let!(:depeche_mode) do
695
705
  Band.create(members: [ "Dave" ])
@@ -848,7 +858,8 @@ describe Mongoid::Contextual::Atomic do
848
858
  end
849
859
  end
850
860
 
851
- context 'when the criteria has a collation', if: collation_supported? do
861
+ context 'when the criteria has a collation' do
862
+ min_server_version '3.4'
852
863
 
853
864
  let!(:depeche_mode) do
854
865
  Band.create(name: "Depeche Mode", years: 10)