mongoid 8.0.3 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +3 -3
- data/README.md +3 -3
- data/lib/config/locales/en.yml +46 -14
- data/lib/mongoid/association/accessors.rb +2 -2
- data/lib/mongoid/association/builders.rb +1 -1
- data/lib/mongoid/association/embedded/batchable.rb +2 -2
- data/lib/mongoid/association/embedded/embedded_in/buildable.rb +2 -2
- data/lib/mongoid/association/embedded/embedded_in/proxy.rb +2 -1
- data/lib/mongoid/association/embedded/embeds_many/buildable.rb +3 -2
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +23 -21
- data/lib/mongoid/association/embedded/embeds_one/buildable.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_one/proxy.rb +1 -1
- data/lib/mongoid/association/nested/one.rb +40 -2
- data/lib/mongoid/association/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/counter_cache.rb +2 -2
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +5 -1
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +2 -2
- data/lib/mongoid/association/referenced/has_many/proxy.rb +7 -3
- data/lib/mongoid/association/reflections.rb +2 -2
- data/lib/mongoid/attributes/dynamic.rb +1 -1
- data/lib/mongoid/attributes/nested.rb +2 -2
- data/lib/mongoid/attributes/projector.rb +1 -1
- data/lib/mongoid/attributes/readonly.rb +1 -1
- data/lib/mongoid/attributes.rb +8 -2
- data/lib/mongoid/changeable.rb +104 -4
- data/lib/mongoid/clients/storage_options.rb +2 -5
- data/lib/mongoid/clients/validators/storage.rb +1 -13
- data/lib/mongoid/collection_configurable.rb +58 -0
- data/lib/mongoid/composable.rb +2 -0
- data/lib/mongoid/config/defaults.rb +60 -0
- data/lib/mongoid/config/validators/async_query_executor.rb +24 -0
- data/lib/mongoid/config/validators.rb +1 -0
- data/lib/mongoid/config.rb +101 -0
- data/lib/mongoid/contextual/atomic.rb +1 -1
- data/lib/mongoid/contextual/memory.rb +233 -33
- data/lib/mongoid/contextual/mongo/documents_loader.rb +177 -0
- data/lib/mongoid/contextual/mongo.rb +373 -113
- data/lib/mongoid/contextual/none.rb +162 -7
- data/lib/mongoid/contextual.rb +12 -0
- data/lib/mongoid/criteria/findable.rb +2 -2
- data/lib/mongoid/criteria/includable.rb +4 -3
- data/lib/mongoid/criteria/queryable/extensions/array.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/hash.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +0 -8
- data/lib/mongoid/criteria/queryable/extensions/string.rb +1 -11
- data/lib/mongoid/criteria/queryable/extensions/symbol.rb +0 -10
- data/lib/mongoid/criteria/queryable/key.rb +1 -1
- data/lib/mongoid/criteria/queryable/mergeable.rb +1 -1
- data/lib/mongoid/criteria/queryable/optional.rb +8 -8
- data/lib/mongoid/criteria/queryable/selectable.rb +43 -12
- data/lib/mongoid/criteria/translator.rb +45 -0
- data/lib/mongoid/criteria.rb +7 -5
- data/lib/mongoid/deprecable.rb +1 -1
- data/lib/mongoid/document.rb +50 -13
- data/lib/mongoid/errors/create_collection_failure.rb +33 -0
- data/lib/mongoid/errors/drop_collection_failure.rb +27 -0
- data/lib/mongoid/errors/immutable_attribute.rb +26 -0
- data/lib/mongoid/errors/invalid_async_query_executor.rb +25 -0
- data/lib/mongoid/errors/invalid_global_executor_concurrency.rb +22 -0
- data/lib/mongoid/errors/invalid_storage_parent.rb +2 -0
- data/lib/mongoid/errors.rb +4 -1
- data/lib/mongoid/extensions/object.rb +2 -2
- data/lib/mongoid/extensions/time.rb +2 -0
- data/lib/mongoid/factory.rb +21 -8
- data/lib/mongoid/fields/localized.rb +10 -0
- data/lib/mongoid/fields/standard.rb +10 -0
- data/lib/mongoid/fields.rb +69 -13
- data/lib/mongoid/findable.rb +27 -3
- data/lib/mongoid/interceptable.rb +7 -6
- data/lib/mongoid/matcher/eq_impl.rb +1 -1
- data/lib/mongoid/matcher/type.rb +1 -1
- data/lib/mongoid/matcher.rb +21 -6
- data/lib/mongoid/persistable/creatable.rb +1 -0
- data/lib/mongoid/persistable/deletable.rb +1 -1
- data/lib/mongoid/persistable/savable.rb +13 -1
- data/lib/mongoid/persistable/unsettable.rb +2 -2
- data/lib/mongoid/persistable/updatable.rb +51 -1
- data/lib/mongoid/persistable/upsertable.rb +20 -1
- data/lib/mongoid/persistable.rb +3 -0
- data/lib/mongoid/query_cache.rb +5 -1
- data/lib/mongoid/railties/database.rake +7 -2
- data/lib/mongoid/shardable.rb +35 -11
- data/lib/mongoid/stateful.rb +22 -1
- data/lib/mongoid/tasks/database.rake +12 -0
- data/lib/mongoid/tasks/database.rb +20 -0
- data/lib/mongoid/threaded.rb +30 -0
- data/lib/mongoid/traversable.rb +1 -1
- data/lib/mongoid/utils.rb +22 -0
- data/lib/mongoid/validatable/macros.rb +5 -5
- data/lib/mongoid/validatable.rb +4 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid/warnings.rb +17 -1
- data/lib/mongoid.rb +16 -3
- data/spec/integration/app_spec.rb +2 -2
- data/spec/integration/callbacks_models.rb +37 -0
- data/spec/integration/callbacks_spec.rb +134 -0
- data/spec/integration/discriminator_key_spec.rb +4 -5
- data/spec/integration/i18n_fallbacks_spec.rb +3 -2
- data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +27 -0
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +57 -57
- data/spec/mongoid/association/embedded/embeds_many_models.rb +1 -0
- data/spec/mongoid/association/embedded/embeds_one/proxy_spec.rb +15 -2
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +2 -18
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +148 -224
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +111 -164
- data/spec/mongoid/association/syncable_spec.rb +1 -1
- data/spec/mongoid/attributes_spec.rb +5 -8
- data/spec/mongoid/changeable_spec.rb +299 -24
- data/spec/mongoid/clients_spec.rb +122 -13
- data/spec/mongoid/collection_configurable_spec.rb +158 -0
- data/spec/mongoid/config/defaults_spec.rb +160 -0
- data/spec/mongoid/config_spec.rb +154 -18
- data/spec/mongoid/contextual/memory_spec.rb +332 -76
- data/spec/mongoid/contextual/mongo/documents_loader_spec.rb +187 -0
- data/spec/mongoid/contextual/mongo_spec.rb +995 -36
- data/spec/mongoid/contextual/none_spec.rb +49 -2
- data/spec/mongoid/copyable_spec.rb +3 -11
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +4 -69
- data/spec/mongoid/criteria/queryable/extensions/symbol_spec.rb +0 -59
- data/spec/mongoid/criteria/queryable/optional_spec.rb +15 -0
- data/spec/mongoid/criteria/queryable/options_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +419 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/selector_spec.rb +1 -1
- data/spec/mongoid/criteria/translator_spec.rb +132 -0
- data/spec/mongoid/criteria_projection_spec.rb +1 -4
- data/spec/mongoid/criteria_spec.rb +5 -9
- data/spec/mongoid/errors/readonly_document_spec.rb +2 -2
- data/spec/mongoid/extensions/time_spec.rb +8 -43
- data/spec/mongoid/extensions/time_with_zone_spec.rb +7 -52
- data/spec/mongoid/fields/localized_spec.rb +46 -28
- data/spec/mongoid/fields_spec.rb +136 -34
- data/spec/mongoid/findable_spec.rb +391 -34
- data/spec/mongoid/indexable_spec.rb +16 -10
- data/spec/mongoid/interceptable_spec.rb +15 -3
- data/spec/mongoid/persistable/deletable_spec.rb +26 -6
- data/spec/mongoid/persistable/destroyable_spec.rb +26 -6
- data/spec/mongoid/persistable/incrementable_spec.rb +37 -0
- data/spec/mongoid/persistable/logical_spec.rb +37 -0
- data/spec/mongoid/persistable/poppable_spec.rb +36 -0
- data/spec/mongoid/persistable/pullable_spec.rb +72 -0
- data/spec/mongoid/persistable/pushable_spec.rb +72 -0
- data/spec/mongoid/persistable/renamable_spec.rb +36 -0
- data/spec/mongoid/persistable/savable_spec.rb +96 -0
- data/spec/mongoid/persistable/settable_spec.rb +37 -0
- data/spec/mongoid/persistable/unsettable_spec.rb +36 -0
- data/spec/mongoid/persistable/updatable_spec.rb +20 -28
- data/spec/mongoid/persistable/upsertable_spec.rb +80 -6
- data/spec/mongoid/persistence_context_spec.rb +7 -57
- data/spec/mongoid/query_cache_spec.rb +56 -61
- data/spec/mongoid/reloadable_spec.rb +24 -4
- data/spec/mongoid/scopable_spec.rb +70 -0
- data/spec/mongoid/serializable_spec.rb +9 -30
- data/spec/mongoid/shardable_models.rb +14 -0
- data/spec/mongoid/shardable_spec.rb +153 -61
- data/spec/mongoid/stateful_spec.rb +122 -8
- data/spec/mongoid/tasks/database_rake_spec.rb +74 -0
- data/spec/mongoid/tasks/database_spec.rb +127 -0
- data/spec/mongoid/timestamps_spec.rb +9 -11
- data/spec/mongoid/touchable_spec.rb +277 -5
- data/spec/mongoid/touchable_spec_models.rb +3 -1
- data/spec/mongoid/traversable_spec.rb +9 -24
- data/spec/mongoid/validatable/uniqueness_spec.rb +2 -3
- data/spec/mongoid_spec.rb +35 -9
- data/spec/shared/lib/mrss/docker_runner.rb +7 -0
- data/spec/shared/lib/mrss/event_subscriber.rb +15 -5
- data/spec/shared/lib/mrss/lite_constraints.rb +10 -2
- data/spec/shared/lib/mrss/server_version_registry.rb +16 -23
- data/spec/shared/lib/mrss/utils.rb +28 -6
- data/spec/shared/share/Dockerfile.erb +36 -40
- data/spec/shared/shlib/server.sh +32 -8
- data/spec/shared/shlib/set_env.sh +4 -4
- data/spec/spec_helper.rb +5 -0
- data/spec/support/immutable_ids.rb +118 -0
- data/spec/support/macros.rb +47 -15
- data/spec/support/models/artist.rb +0 -1
- data/spec/support/models/band.rb +1 -0
- data/spec/support/models/book.rb +1 -0
- data/spec/support/models/building.rb +2 -0
- data/spec/support/models/cover.rb +10 -0
- data/spec/support/models/product.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +700 -656
- metadata.gz.sig +0 -0
- data/spec/mongoid/criteria/queryable/extensions/bignum_spec.rb +0 -60
- data/spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb +0 -60
|
@@ -54,8 +54,17 @@ describe Mongoid::Contextual::None do
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
describe "#pluck" do
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
|
|
58
|
+
context "when plucking one field" do
|
|
59
|
+
it "returns an empty array" do
|
|
60
|
+
expect(context.pluck(:id)).to eq([])
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
context "when plucking multiple fields" do
|
|
65
|
+
it "returns an empty array" do
|
|
66
|
+
expect(context.pluck(:id, :foo)).to eq([])
|
|
67
|
+
end
|
|
59
68
|
end
|
|
60
69
|
end
|
|
61
70
|
|
|
@@ -81,6 +90,14 @@ describe Mongoid::Contextual::None do
|
|
|
81
90
|
end
|
|
82
91
|
end
|
|
83
92
|
|
|
93
|
+
describe "#first!" do
|
|
94
|
+
it "raises an error" do
|
|
95
|
+
expect do
|
|
96
|
+
context.first!
|
|
97
|
+
end.to raise_error(Mongoid::Errors::DocumentNotFound, /Could not find a document of class Band./)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
84
101
|
describe "#last" do
|
|
85
102
|
it "returns nil" do
|
|
86
103
|
expect(context.last).to be_nil
|
|
@@ -91,6 +108,14 @@ describe Mongoid::Contextual::None do
|
|
|
91
108
|
end
|
|
92
109
|
end
|
|
93
110
|
|
|
111
|
+
describe "#last!" do
|
|
112
|
+
it "raises an error" do
|
|
113
|
+
expect do
|
|
114
|
+
context.last!
|
|
115
|
+
end.to raise_error(Mongoid::Errors::DocumentNotFound, /Could not find a document of class Band./)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
94
119
|
describe "#take" do
|
|
95
120
|
it "returns nil" do
|
|
96
121
|
expect(context.take).to be_nil
|
|
@@ -109,6 +134,28 @@ describe Mongoid::Contextual::None do
|
|
|
109
134
|
end
|
|
110
135
|
end
|
|
111
136
|
|
|
137
|
+
[ :second,
|
|
138
|
+
:third,
|
|
139
|
+
:fourth,
|
|
140
|
+
:fifth,
|
|
141
|
+
:second_to_last,
|
|
142
|
+
:third_to_last
|
|
143
|
+
].each do |meth|
|
|
144
|
+
describe "##{meth}" do
|
|
145
|
+
it "returns nil" do
|
|
146
|
+
expect(context.send(meth)).to be_nil
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe "##{meth}!" do
|
|
151
|
+
it "raises an error" do
|
|
152
|
+
expect do
|
|
153
|
+
context.send("#{meth}!")
|
|
154
|
+
end.to raise_error(Mongoid::Errors::DocumentNotFound, /Could not find a document of class Band./)
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
112
159
|
describe "#length" do
|
|
113
160
|
it "returns zero" do
|
|
114
161
|
expect(context.length).to eq(0)
|
|
@@ -90,7 +90,7 @@ describe Mongoid::Copyable do
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
it 'calls constructor with explicitly declared attributes only' do
|
|
93
|
-
expect(Mongoid::Factory).to receive(:build).with(cls, 'name' => 'test').and_call_original
|
|
93
|
+
expect(Mongoid::Factory).to receive(:build).with(cls, { 'name' => 'test' }).and_call_original
|
|
94
94
|
cloned
|
|
95
95
|
end
|
|
96
96
|
end
|
|
@@ -164,19 +164,15 @@ describe Mongoid::Copyable do
|
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
context "when cloning a document with multiple languages field" do
|
|
167
|
+
with_default_i18n_configs
|
|
167
168
|
|
|
168
169
|
before do
|
|
169
|
-
I18n.enforce_available_locales = false
|
|
170
170
|
I18n.locale = 'pt_BR'
|
|
171
171
|
person.desc = "descrição"
|
|
172
172
|
person.addresses.first.name = "descrição"
|
|
173
173
|
person.save!
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
-
after do
|
|
177
|
-
I18n.locale = :en
|
|
178
|
-
end
|
|
179
|
-
|
|
180
176
|
let!(:from_db) do
|
|
181
177
|
Person.find(person.id)
|
|
182
178
|
end
|
|
@@ -212,22 +208,18 @@ describe Mongoid::Copyable do
|
|
|
212
208
|
end
|
|
213
209
|
|
|
214
210
|
context "when cloning a document with polymorphic embedded documents with multiple language field" do
|
|
211
|
+
with_default_i18n_configs
|
|
215
212
|
|
|
216
213
|
let!(:shipment_address) do
|
|
217
214
|
person.addresses.build({ shipping_name: "Title" }, ShipmentAddress)
|
|
218
215
|
end
|
|
219
216
|
|
|
220
217
|
before do
|
|
221
|
-
I18n.enforce_available_locales = false
|
|
222
218
|
I18n.locale = 'pt_BR'
|
|
223
219
|
person.addresses.type(ShipmentAddress).each { |address| address.shipping_name = "Título" }
|
|
224
220
|
person.save!
|
|
225
221
|
end
|
|
226
222
|
|
|
227
|
-
after do
|
|
228
|
-
I18n.locale = :en
|
|
229
|
-
end
|
|
230
|
-
|
|
231
223
|
let!(:from_db) do
|
|
232
224
|
Person.find(person.id)
|
|
233
225
|
end
|
|
@@ -72,11 +72,8 @@ describe String do
|
|
|
72
72
|
context "when the string without timezone" do
|
|
73
73
|
|
|
74
74
|
context "when using active support's time zone" do
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Mongoid.use_activesupport_time_zone = true
|
|
78
|
-
::Time.zone = "Tokyo"
|
|
79
|
-
end
|
|
75
|
+
config_override :use_activesupport_time_zone, true
|
|
76
|
+
time_zone_override "Tokyo"
|
|
80
77
|
|
|
81
78
|
let(:date) do
|
|
82
79
|
"2010-01-01 5:00:00"
|
|
@@ -92,11 +89,8 @@ describe String do
|
|
|
92
89
|
end
|
|
93
90
|
|
|
94
91
|
context "when not using active support's time zone" do
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Mongoid.use_activesupport_time_zone = false
|
|
98
|
-
::Time.zone = nil
|
|
99
|
-
end
|
|
92
|
+
config_override :use_activesupport_time_zone, false
|
|
93
|
+
time_zone_override nil
|
|
100
94
|
|
|
101
95
|
let(:date) do
|
|
102
96
|
"2010-01-01 5:00:00"
|
|
@@ -253,65 +247,6 @@ describe String do
|
|
|
253
247
|
end
|
|
254
248
|
end
|
|
255
249
|
|
|
256
|
-
describe "#to_direction" do
|
|
257
|
-
|
|
258
|
-
context "when ascending" do
|
|
259
|
-
|
|
260
|
-
it "returns 1" do
|
|
261
|
-
expect("ascending".to_direction).to eq(1)
|
|
262
|
-
end
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
context "when asc" do
|
|
266
|
-
|
|
267
|
-
it "returns 1" do
|
|
268
|
-
expect("asc".to_direction).to eq(1)
|
|
269
|
-
end
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
context "when ASCENDING" do
|
|
273
|
-
|
|
274
|
-
it "returns 1" do
|
|
275
|
-
expect("ASCENDING".to_direction).to eq(1)
|
|
276
|
-
end
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
context "when ASC" do
|
|
280
|
-
|
|
281
|
-
it "returns 1" do
|
|
282
|
-
expect("ASC".to_direction).to eq(1)
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
context "when descending" do
|
|
287
|
-
|
|
288
|
-
it "returns -1" do
|
|
289
|
-
expect("descending".to_direction).to eq(-1)
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
context "when desc" do
|
|
294
|
-
|
|
295
|
-
it "returns -1" do
|
|
296
|
-
expect("desc".to_direction).to eq(-1)
|
|
297
|
-
end
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
context "when DESCENDING" do
|
|
301
|
-
|
|
302
|
-
it "returns -1" do
|
|
303
|
-
expect("DESCENDING".to_direction).to eq(-1)
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
context "when DESC" do
|
|
308
|
-
|
|
309
|
-
it "returns -1" do
|
|
310
|
-
expect("DESC".to_direction).to eq(-1)
|
|
311
|
-
end
|
|
312
|
-
end
|
|
313
|
-
end
|
|
314
|
-
|
|
315
250
|
describe ".evolve" do
|
|
316
251
|
|
|
317
252
|
context "when provided a regex" do
|
|
@@ -107,63 +107,4 @@ describe Symbol do
|
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
|
-
|
|
111
|
-
describe "#to_direction" do
|
|
112
|
-
|
|
113
|
-
context "when ascending" do
|
|
114
|
-
|
|
115
|
-
it "returns 1" do
|
|
116
|
-
expect(:ascending.to_direction).to eq(1)
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
context "when asc" do
|
|
121
|
-
|
|
122
|
-
it "returns 1" do
|
|
123
|
-
expect(:asc.to_direction).to eq(1)
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
context "when ASCENDING" do
|
|
128
|
-
|
|
129
|
-
it "returns 1" do
|
|
130
|
-
expect(:ASCENDING.to_direction).to eq(1)
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
context "when ASC" do
|
|
135
|
-
|
|
136
|
-
it "returns 1" do
|
|
137
|
-
expect(:ASC.to_direction).to eq(1)
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
context "when descending" do
|
|
142
|
-
|
|
143
|
-
it "returns -1" do
|
|
144
|
-
expect(:descending.to_direction).to eq(-1)
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
context "when desc" do
|
|
149
|
-
|
|
150
|
-
it "returns -1" do
|
|
151
|
-
expect(:desc.to_direction).to eq(-1)
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
context "when DESCENDING" do
|
|
156
|
-
|
|
157
|
-
it "returns -1" do
|
|
158
|
-
expect(:DESCENDING.to_direction).to eq(-1)
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
context "when DESC" do
|
|
163
|
-
|
|
164
|
-
it "returns -1" do
|
|
165
|
-
expect(:DESC.to_direction).to eq(-1)
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
110
|
end
|
|
@@ -741,6 +741,21 @@ describe Mongoid::Criteria::Queryable::Optional do
|
|
|
741
741
|
|
|
742
742
|
it_behaves_like "a cloning option"
|
|
743
743
|
end
|
|
744
|
+
|
|
745
|
+
context "when the hash has hash values" do
|
|
746
|
+
|
|
747
|
+
let(:selection) do
|
|
748
|
+
query.send("#{method}", score: { "$meta" => "textScore"})
|
|
749
|
+
end
|
|
750
|
+
|
|
751
|
+
it "adds the sorting criteria" do
|
|
752
|
+
expect(selection.options).to eq(
|
|
753
|
+
{ sort: { "score" => { "$meta" => "textScore" } }}
|
|
754
|
+
)
|
|
755
|
+
end
|
|
756
|
+
|
|
757
|
+
it_behaves_like "a cloning option"
|
|
758
|
+
end
|
|
744
759
|
end
|
|
745
760
|
|
|
746
761
|
context "when provided an array" do
|
|
@@ -221,6 +221,7 @@ describe Mongoid::Criteria::Queryable::Options do
|
|
|
221
221
|
end
|
|
222
222
|
|
|
223
223
|
context "when the serializer is localized" do
|
|
224
|
+
with_default_i18n_configs
|
|
224
225
|
|
|
225
226
|
before(:all) do
|
|
226
227
|
class Field
|
|
@@ -232,7 +233,6 @@ describe Mongoid::Criteria::Queryable::Options do
|
|
|
232
233
|
|
|
233
234
|
after(:all) do
|
|
234
235
|
Object.send(:remove_const, :Field)
|
|
235
|
-
::I18n.locale = :en
|
|
236
236
|
end
|
|
237
237
|
|
|
238
238
|
let(:options) do
|