mongoid 8.0.5 → 8.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +3 -3
  4. data/README.md +3 -3
  5. data/lib/config/locales/en.yml +46 -14
  6. data/lib/mongoid/association/accessors.rb +2 -2
  7. data/lib/mongoid/association/builders.rb +1 -1
  8. data/lib/mongoid/association/embedded/batchable.rb +2 -2
  9. data/lib/mongoid/association/embedded/embedded_in/buildable.rb +2 -2
  10. data/lib/mongoid/association/embedded/embedded_in/proxy.rb +2 -1
  11. data/lib/mongoid/association/embedded/embeds_many/buildable.rb +3 -2
  12. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +6 -6
  13. data/lib/mongoid/association/embedded/embeds_one/buildable.rb +1 -1
  14. data/lib/mongoid/association/embedded/embeds_one/proxy.rb +1 -1
  15. data/lib/mongoid/association/nested/one.rb +40 -2
  16. data/lib/mongoid/association/proxy.rb +1 -1
  17. data/lib/mongoid/association/referenced/counter_cache.rb +2 -2
  18. data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +1 -1
  19. data/lib/mongoid/association/referenced/has_many/enumerable.rb +2 -2
  20. data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
  21. data/lib/mongoid/association/reflections.rb +2 -2
  22. data/lib/mongoid/attributes/dynamic.rb +1 -1
  23. data/lib/mongoid/attributes/nested.rb +2 -2
  24. data/lib/mongoid/attributes/projector.rb +1 -1
  25. data/lib/mongoid/attributes/readonly.rb +1 -1
  26. data/lib/mongoid/attributes.rb +8 -2
  27. data/lib/mongoid/changeable.rb +104 -4
  28. data/lib/mongoid/clients/storage_options.rb +2 -5
  29. data/lib/mongoid/clients/validators/storage.rb +1 -13
  30. data/lib/mongoid/collection_configurable.rb +58 -0
  31. data/lib/mongoid/composable.rb +2 -0
  32. data/lib/mongoid/config/defaults.rb +60 -0
  33. data/lib/mongoid/config/validators/async_query_executor.rb +24 -0
  34. data/lib/mongoid/config/validators.rb +1 -0
  35. data/lib/mongoid/config.rb +101 -0
  36. data/lib/mongoid/contextual/atomic.rb +1 -1
  37. data/lib/mongoid/contextual/memory.rb +233 -33
  38. data/lib/mongoid/contextual/mongo/documents_loader.rb +177 -0
  39. data/lib/mongoid/contextual/mongo.rb +373 -113
  40. data/lib/mongoid/contextual/none.rb +162 -7
  41. data/lib/mongoid/contextual.rb +12 -0
  42. data/lib/mongoid/criteria/findable.rb +2 -2
  43. data/lib/mongoid/criteria/includable.rb +4 -3
  44. data/lib/mongoid/criteria/queryable/key.rb +1 -1
  45. data/lib/mongoid/criteria/queryable/mergeable.rb +1 -1
  46. data/lib/mongoid/criteria/queryable/optional.rb +8 -8
  47. data/lib/mongoid/criteria/queryable/selectable.rb +43 -12
  48. data/lib/mongoid/criteria.rb +6 -5
  49. data/lib/mongoid/deprecable.rb +1 -1
  50. data/lib/mongoid/errors/create_collection_failure.rb +33 -0
  51. data/lib/mongoid/errors/drop_collection_failure.rb +27 -0
  52. data/lib/mongoid/errors/immutable_attribute.rb +26 -0
  53. data/lib/mongoid/errors/invalid_async_query_executor.rb +25 -0
  54. data/lib/mongoid/errors/invalid_global_executor_concurrency.rb +22 -0
  55. data/lib/mongoid/errors/invalid_storage_parent.rb +2 -0
  56. data/lib/mongoid/errors.rb +4 -1
  57. data/lib/mongoid/extensions/object.rb +2 -2
  58. data/lib/mongoid/extensions/time.rb +2 -0
  59. data/lib/mongoid/fields/localized.rb +10 -0
  60. data/lib/mongoid/fields/standard.rb +10 -0
  61. data/lib/mongoid/fields.rb +69 -13
  62. data/lib/mongoid/findable.rb +27 -3
  63. data/lib/mongoid/interceptable.rb +7 -6
  64. data/lib/mongoid/matcher/eq_impl.rb +1 -1
  65. data/lib/mongoid/matcher/type.rb +1 -1
  66. data/lib/mongoid/persistable/creatable.rb +1 -0
  67. data/lib/mongoid/persistable/deletable.rb +1 -1
  68. data/lib/mongoid/persistable/savable.rb +13 -1
  69. data/lib/mongoid/persistable/unsettable.rb +2 -2
  70. data/lib/mongoid/persistable/updatable.rb +51 -1
  71. data/lib/mongoid/persistable/upsertable.rb +20 -1
  72. data/lib/mongoid/persistable.rb +3 -0
  73. data/lib/mongoid/query_cache.rb +5 -1
  74. data/lib/mongoid/railties/database.rake +7 -2
  75. data/lib/mongoid/stateful.rb +22 -1
  76. data/lib/mongoid/tasks/database.rake +12 -0
  77. data/lib/mongoid/tasks/database.rb +20 -0
  78. data/lib/mongoid/utils.rb +22 -0
  79. data/lib/mongoid/validatable/macros.rb +5 -5
  80. data/lib/mongoid/validatable.rb +4 -1
  81. data/lib/mongoid/version.rb +1 -1
  82. data/lib/mongoid/warnings.rb +17 -1
  83. data/lib/mongoid.rb +16 -3
  84. data/spec/integration/app_spec.rb +2 -2
  85. data/spec/integration/callbacks_models.rb +37 -0
  86. data/spec/integration/callbacks_spec.rb +134 -0
  87. data/spec/integration/discriminator_key_spec.rb +4 -5
  88. data/spec/integration/i18n_fallbacks_spec.rb +3 -2
  89. data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +27 -0
  90. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +20 -25
  91. data/spec/mongoid/association/embedded/embeds_many_models.rb +1 -0
  92. data/spec/mongoid/association/embedded/embeds_one/proxy_spec.rb +15 -2
  93. data/spec/mongoid/association/referenced/belongs_to_spec.rb +2 -18
  94. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +5 -27
  95. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +9 -50
  96. data/spec/mongoid/association/syncable_spec.rb +1 -1
  97. data/spec/mongoid/attributes_spec.rb +3 -6
  98. data/spec/mongoid/changeable_spec.rb +299 -24
  99. data/spec/mongoid/clients_spec.rb +122 -13
  100. data/spec/mongoid/collection_configurable_spec.rb +158 -0
  101. data/spec/mongoid/config/defaults_spec.rb +160 -0
  102. data/spec/mongoid/config_spec.rb +154 -18
  103. data/spec/mongoid/contextual/memory_spec.rb +332 -76
  104. data/spec/mongoid/contextual/mongo/documents_loader_spec.rb +187 -0
  105. data/spec/mongoid/contextual/mongo_spec.rb +995 -36
  106. data/spec/mongoid/contextual/none_spec.rb +49 -2
  107. data/spec/mongoid/copyable_spec.rb +3 -11
  108. data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +4 -10
  109. data/spec/mongoid/criteria/queryable/options_spec.rb +1 -1
  110. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +419 -0
  111. data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -1
  112. data/spec/mongoid/criteria/queryable/selector_spec.rb +1 -1
  113. data/spec/mongoid/criteria_projection_spec.rb +1 -4
  114. data/spec/mongoid/criteria_spec.rb +5 -9
  115. data/spec/mongoid/errors/readonly_document_spec.rb +2 -2
  116. data/spec/mongoid/extensions/time_spec.rb +8 -43
  117. data/spec/mongoid/extensions/time_with_zone_spec.rb +7 -52
  118. data/spec/mongoid/fields/localized_spec.rb +46 -28
  119. data/spec/mongoid/fields_spec.rb +136 -34
  120. data/spec/mongoid/findable_spec.rb +391 -34
  121. data/spec/mongoid/indexable_spec.rb +16 -10
  122. data/spec/mongoid/interceptable_spec.rb +15 -3
  123. data/spec/mongoid/persistable/deletable_spec.rb +26 -6
  124. data/spec/mongoid/persistable/destroyable_spec.rb +26 -6
  125. data/spec/mongoid/persistable/incrementable_spec.rb +37 -0
  126. data/spec/mongoid/persistable/logical_spec.rb +37 -0
  127. data/spec/mongoid/persistable/poppable_spec.rb +36 -0
  128. data/spec/mongoid/persistable/pullable_spec.rb +72 -0
  129. data/spec/mongoid/persistable/pushable_spec.rb +72 -0
  130. data/spec/mongoid/persistable/renamable_spec.rb +36 -0
  131. data/spec/mongoid/persistable/savable_spec.rb +96 -0
  132. data/spec/mongoid/persistable/settable_spec.rb +37 -0
  133. data/spec/mongoid/persistable/unsettable_spec.rb +36 -0
  134. data/spec/mongoid/persistable/updatable_spec.rb +20 -28
  135. data/spec/mongoid/persistable/upsertable_spec.rb +80 -6
  136. data/spec/mongoid/persistence_context_spec.rb +7 -57
  137. data/spec/mongoid/query_cache_spec.rb +56 -61
  138. data/spec/mongoid/reloadable_spec.rb +25 -5
  139. data/spec/mongoid/scopable_spec.rb +70 -0
  140. data/spec/mongoid/serializable_spec.rb +9 -30
  141. data/spec/mongoid/stateful_spec.rb +122 -8
  142. data/spec/mongoid/tasks/database_rake_spec.rb +74 -0
  143. data/spec/mongoid/tasks/database_spec.rb +127 -0
  144. data/spec/mongoid/timestamps_spec.rb +9 -11
  145. data/spec/mongoid/touchable_spec.rb +277 -5
  146. data/spec/mongoid/touchable_spec_models.rb +3 -1
  147. data/spec/mongoid/traversable_spec.rb +9 -24
  148. data/spec/mongoid/validatable/uniqueness_spec.rb +2 -3
  149. data/spec/mongoid_spec.rb +33 -9
  150. data/spec/shared/lib/mrss/docker_runner.rb +7 -0
  151. data/spec/shared/lib/mrss/event_subscriber.rb +15 -5
  152. data/spec/shared/lib/mrss/lite_constraints.rb +10 -2
  153. data/spec/shared/lib/mrss/server_version_registry.rb +16 -23
  154. data/spec/shared/lib/mrss/utils.rb +28 -6
  155. data/spec/shared/share/Dockerfile.erb +36 -40
  156. data/spec/shared/shlib/server.sh +32 -8
  157. data/spec/shared/shlib/set_env.sh +4 -4
  158. data/spec/spec_helper.rb +5 -0
  159. data/spec/support/immutable_ids.rb +118 -0
  160. data/spec/support/macros.rb +47 -15
  161. data/spec/support/models/artist.rb +0 -1
  162. data/spec/support/models/band.rb +1 -0
  163. data/spec/support/models/book.rb +1 -0
  164. data/spec/support/models/building.rb +2 -0
  165. data/spec/support/models/cover.rb +10 -0
  166. data/spec/support/models/product.rb +1 -0
  167. data.tar.gz.sig +0 -0
  168. metadata +42 -6
  169. metadata.gz.sig +0 -0
  170. data/spec/mongoid/criteria/queryable/extensions/bignum_spec.rb +0 -60
  171. data/spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb +0 -60
@@ -0,0 +1,160 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "spec_helper"
4
+
5
+ describe Mongoid::Config::Defaults do
6
+
7
+ let(:config) do
8
+ Mongoid::Config
9
+ end
10
+
11
+ describe ".load_defaults" do
12
+
13
+ shared_examples "uses settings for 7.3" do
14
+ it "uses settings for 7.3" do
15
+ expect(Mongoid.broken_aggregables).to be true
16
+ expect(Mongoid.broken_alias_handling).to be true
17
+ expect(Mongoid.broken_and).to be true
18
+ expect(Mongoid.broken_scoping).to be true
19
+ expect(Mongoid.broken_updates).to be true
20
+ expect(Mongoid.compare_time_by_ms).to be false
21
+ expect(Mongoid.legacy_pluck_distinct).to be true
22
+ expect(Mongoid.legacy_triple_equals).to be true
23
+ expect(Mongoid.object_id_as_json_oid).to be true
24
+ end
25
+ end
26
+
27
+ shared_examples "does not use settings for 7.3" do
28
+ it "does not use settings for 7.3" do
29
+ expect(Mongoid.broken_aggregables).to be false
30
+ expect(Mongoid.broken_alias_handling).to be false
31
+ expect(Mongoid.broken_and).to be false
32
+ expect(Mongoid.broken_scoping).to be false
33
+ expect(Mongoid.broken_updates).to be false
34
+ expect(Mongoid.compare_time_by_ms).to be true
35
+ expect(Mongoid.legacy_pluck_distinct).to be false
36
+ expect(Mongoid.legacy_triple_equals).to be false
37
+ end
38
+ end
39
+
40
+ shared_examples "uses settings for 7.4" do
41
+ it "uses settings for 7.4" do
42
+ expect(Mongoid.legacy_attributes).to be true
43
+ expect(Mongoid.overwrite_chained_operators).to be true
44
+ end
45
+ end
46
+
47
+ shared_examples "does not use settings for 7.4" do
48
+ it "does not use settings for 7.4" do
49
+ expect(Mongoid.legacy_attributes).to be false
50
+ expect(Mongoid.overwrite_chained_operators).to be false
51
+ end
52
+ end
53
+
54
+ shared_examples "uses settings for 7.5" do
55
+ it "uses settings for 7.5" do
56
+ expect(Mongoid.map_big_decimal_to_decimal128).to be false
57
+ end
58
+ end
59
+
60
+ shared_examples "does not use settings for 7.5" do
61
+ it "does not use settings for 7.5" do
62
+ expect(Mongoid.map_big_decimal_to_decimal128).to be true
63
+ end
64
+ end
65
+
66
+ shared_examples "uses settings for 8.0" do
67
+ it "uses settings for 8.0" do
68
+ expect(Mongoid.legacy_readonly).to be true
69
+ end
70
+ end
71
+
72
+ shared_examples "does not use settings for 8.0" do
73
+ it "does not use settings for 8.0" do
74
+ expect(Mongoid.legacy_readonly).to be false
75
+ end
76
+ end
77
+
78
+ shared_examples "uses settings for 8.1" do
79
+ it "uses settings for 8.1" do
80
+ expect(Mongoid.immutable_ids).to be false
81
+ end
82
+ end
83
+
84
+ context "when giving a valid version" do
85
+
86
+ before do
87
+ config.load_defaults(version)
88
+ end
89
+
90
+ after do
91
+ Mongoid::Config.reset
92
+ end
93
+
94
+ context "when the given version is 7.3" do
95
+
96
+ let(:version) { 7.3 }
97
+
98
+ it_behaves_like "uses settings for 7.3"
99
+ it_behaves_like "uses settings for 7.4"
100
+ it_behaves_like "uses settings for 7.5"
101
+ it_behaves_like "uses settings for 8.0"
102
+ it_behaves_like "uses settings for 8.1"
103
+ end
104
+
105
+ context "when the given version is 7.4" do
106
+
107
+ let(:version) { 7.4 }
108
+
109
+ it_behaves_like "does not use settings for 7.3"
110
+ it_behaves_like "uses settings for 7.4"
111
+ it_behaves_like "uses settings for 7.5"
112
+ it_behaves_like "uses settings for 8.0"
113
+ it_behaves_like "uses settings for 8.1"
114
+ end
115
+
116
+ context "when the given version is 7.5" do
117
+
118
+ let(:version) { 7.5 }
119
+
120
+ it_behaves_like "does not use settings for 7.3"
121
+ it_behaves_like "does not use settings for 7.4"
122
+ it_behaves_like "uses settings for 7.5"
123
+ it_behaves_like "uses settings for 8.0"
124
+ it_behaves_like "uses settings for 8.1"
125
+ end
126
+
127
+ context "when the given version is 8.0" do
128
+
129
+ let(:version) { 8.0 }
130
+
131
+ it_behaves_like "does not use settings for 7.3"
132
+ it_behaves_like "does not use settings for 7.4"
133
+ it_behaves_like "does not use settings for 7.5"
134
+ it_behaves_like "uses settings for 8.0"
135
+ it_behaves_like "uses settings for 8.1"
136
+ end
137
+
138
+ context "when the given version is 8.1" do
139
+
140
+ let(:version) { 8.1 }
141
+
142
+ it_behaves_like "does not use settings for 7.3"
143
+ it_behaves_like "does not use settings for 7.4"
144
+ it_behaves_like "does not use settings for 7.5"
145
+ it_behaves_like "does not use settings for 8.0"
146
+ it_behaves_like "uses settings for 8.1"
147
+ end
148
+ end
149
+
150
+ context "when given version an invalid version" do
151
+ let(:version) { 4.2 }
152
+
153
+ it "raises an error" do
154
+ expect do
155
+ config.load_defaults(version)
156
+ end.to raise_error(ArgumentError, /Unknown version: 4.2/)
157
+ end
158
+ end
159
+ end
160
+ end
@@ -224,6 +224,79 @@ describe Mongoid::Config do
224
224
  end
225
225
  end
226
226
 
227
+ context 'async_query_executor option' do
228
+ let(:option) { :async_query_executor }
229
+
230
+ before do
231
+ Mongoid::Config.reset
232
+ Mongoid.configure do |config|
233
+ config.load_configuration(conf)
234
+ end
235
+ end
236
+
237
+ context "when it is not set in the config" do
238
+
239
+ let(:conf) { CONFIG }
240
+
241
+ it "it is set to its default" do
242
+ expect(Mongoid.send(option)).to eq(:immediate)
243
+ end
244
+ end
245
+
246
+ context 'when the value is :immediate' do
247
+
248
+ let(:conf) do
249
+ CONFIG.merge(options: { option => :immediate })
250
+ end
251
+
252
+ it "is set to false" do
253
+ expect(Mongoid.send(option)).to be(:immediate)
254
+ end
255
+ end
256
+
257
+ context 'when the value is :global_thread_pool' do
258
+
259
+ let(:conf) do
260
+ CONFIG.merge(options: { option => :global_thread_pool })
261
+ end
262
+
263
+ it "is set to false" do
264
+ expect(Mongoid.send(option)).to be(:global_thread_pool)
265
+ end
266
+ end
267
+ end
268
+
269
+ context 'global_executor_concurrency option' do
270
+ let(:option) { :global_executor_concurrency }
271
+
272
+ before do
273
+ Mongoid::Config.reset
274
+ Mongoid.configure do |config|
275
+ config.load_configuration(conf)
276
+ end
277
+ end
278
+
279
+ context "when it is not set in the config" do
280
+
281
+ let(:conf) { CONFIG }
282
+
283
+ it "it is set to its default" do
284
+ expect(Mongoid.send(option)).to eq(nil)
285
+ end
286
+ end
287
+
288
+ context 'when the value is set to a number' do
289
+
290
+ let(:conf) do
291
+ CONFIG.merge(options: { option => 5 })
292
+ end
293
+
294
+ it "is set to the number" do
295
+ expect(Mongoid.send(option)).to be(5)
296
+ end
297
+ end
298
+ end
299
+
227
300
  shared_examples "a config option" do
228
301
 
229
302
  before do
@@ -349,6 +422,13 @@ describe Mongoid::Config do
349
422
  it_behaves_like "a config option"
350
423
  end
351
424
 
425
+ context 'when setting the legacy_readonly option in the config' do
426
+ let(:option) { :legacy_readonly }
427
+ let(:default) { true }
428
+
429
+ it_behaves_like "a config option"
430
+ end
431
+
352
432
  describe "#load!" do
353
433
 
354
434
  before(:all) do
@@ -599,24 +679,26 @@ describe Mongoid::Config do
599
679
 
600
680
  it 'passes uuid to driver' do
601
681
  Mongo::Client.should receive(:new).with(SpecConfig.instance.addresses,
602
- auto_encryption_options: {
603
- 'key_vault_namespace' => 'admin.datakeys',
604
- 'kms_providers' => {'local' => {'key' => 'z7iYiYKLuYymEWtk4kfny1ESBwwFdA58qMqff96A8ghiOcIK75lJGPUIocku8LOFjQuEgeIP4xlln3s7r93FV9J5sAE7zg8U'}},
605
- 'schema_map' => {'blog_development.comments' => {
606
- 'bsonType' => 'object',
607
- 'properties' => {
608
- 'message' => {'encrypt' => {
609
- 'algorithm' => 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic',
610
- 'bsonType' => 'string',
611
- 'keyId' => [BSON::Binary.new("G\xF0 5\xCC@HX\xA2%b\x97\xA9a\xA8\xE7", :uuid)],
612
- }},
613
- },
614
- }}},
615
- database: 'mongoid_test',
616
- platform: "mongoid-#{Mongoid::VERSION}",
617
- wrapping_libraries: [
618
- {'name' => 'Mongoid', 'version' => Mongoid::VERSION},
619
- ],
682
+ {
683
+ auto_encryption_options: {
684
+ 'key_vault_namespace' => 'admin.datakeys',
685
+ 'kms_providers' => { 'local' => { 'key' => 'z7iYiYKLuYymEWtk4kfny1ESBwwFdA58qMqff96A8ghiOcIK75lJGPUIocku8LOFjQuEgeIP4xlln3s7r93FV9J5sAE7zg8U' } },
686
+ 'schema_map' => { 'blog_development.comments' => {
687
+ 'bsonType' => 'object',
688
+ 'properties' => {
689
+ 'message' => { 'encrypt' => {
690
+ 'algorithm' => 'AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic',
691
+ 'bsonType' => 'string',
692
+ 'keyId' => [BSON::Binary.new("G\xF0 5\xCC@HX\xA2%b\x97\xA9a\xA8\xE7", :uuid)],
693
+ } },
694
+ },
695
+ } } },
696
+ database: 'mongoid_test',
697
+ platform: "mongoid-#{Mongoid::VERSION}",
698
+ wrapping_libraries: [
699
+ { 'name' => 'Mongoid', 'version' => Mongoid::VERSION },
700
+ ],
701
+ }
620
702
  )
621
703
 
622
704
  client
@@ -645,6 +727,17 @@ describe Mongoid::Config do
645
727
  }.to raise_error(Mongoid::Errors::InvalidConfigOption)
646
728
  end
647
729
  end
730
+
731
+ context 'when invalid global_executor_concurrency option provided' do
732
+ it "raises an error" do
733
+ expect do
734
+ described_class.options = {
735
+ async_query_executor: :immediate,
736
+ global_executor_concurrency: 5
737
+ }
738
+ end.to raise_error(Mongoid::Errors::InvalidGlobalExecutorConcurrency)
739
+ end
740
+ end
648
741
  end
649
742
 
650
743
  describe "#clients=" do
@@ -845,4 +938,47 @@ describe Mongoid::Config do
845
938
  end
846
939
  end
847
940
  end
941
+
942
+ describe 'deprecations' do
943
+ { use_activesupport_time_zone: true,
944
+ broken_aggregables: false,
945
+ broken_alias_handling: false,
946
+ broken_and: false,
947
+ broken_scoping: false,
948
+ broken_updates: false,
949
+ compare_time_by_ms: true,
950
+ legacy_attributes: false,
951
+ legacy_pluck_distinct: false,
952
+ legacy_triple_equals: false,
953
+ object_id_as_json_oid: false,
954
+ overwrite_chained_operators: false }.each do |option, default|
955
+
956
+ context ":#{option} option" do
957
+
958
+ before do
959
+ Mongoid::Warnings.class_eval do
960
+ instance_variable_set(:"@#{option}_deprecated", false)
961
+ end
962
+ end
963
+
964
+ let(:matcher) do
965
+ /Config option :#{option}.+\. It will always be #{default} beginning in Mongoid 9\.0\./
966
+ end
967
+
968
+ context 'when set to true' do
969
+ it 'gives a deprecation warning' do
970
+ expect(Mongoid.logger).to receive(:warn).with(matcher)
971
+ described_class.send(:"#{option}=", true)
972
+ end
973
+ end
974
+
975
+ context 'when set to false' do
976
+ it 'gives a deprecation warning' do
977
+ expect(Mongoid.logger).to receive(:warn).with(matcher)
978
+ described_class.send(:"#{option}=", false)
979
+ end
980
+ end
981
+ end
982
+ end
983
+ end
848
984
  end