mongoid 7.2.6 → 7.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Rakefile +16 -0
- data/lib/config/locales/en.yml +2 -2
- data/lib/mongoid/association/accessors.rb +13 -1
- data/lib/mongoid/association/constrainable.rb +1 -1
- data/lib/mongoid/association/depending.rb +4 -4
- data/lib/mongoid/association/embedded/batchable.rb +1 -1
- data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +10 -3
- data/lib/mongoid/association/nested/many.rb +1 -1
- data/lib/mongoid/association/nested/one.rb +4 -2
- data/lib/mongoid/association/proxy.rb +6 -1
- data/lib/mongoid/association/referenced/auto_save.rb +2 -2
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +490 -496
- data/lib/mongoid/association/referenced/has_many/proxy.rb +2 -2
- data/lib/mongoid/association/referenced/has_one/nested_builder.rb +2 -2
- data/lib/mongoid/atomic.rb +26 -2
- data/lib/mongoid/attributes/projector.rb +120 -0
- data/lib/mongoid/attributes.rb +24 -13
- data/lib/mongoid/cacheable.rb +2 -2
- data/lib/mongoid/clients/factory.rb +22 -8
- data/lib/mongoid/clients.rb +1 -1
- data/lib/mongoid/config.rb +19 -2
- data/lib/mongoid/contextual/aggregable/mongo.rb +10 -8
- data/lib/mongoid/copyable.rb +1 -1
- data/lib/mongoid/criteria/findable.rb +1 -1
- data/lib/mongoid/criteria/queryable/expandable.rb +0 -24
- data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions.rb +0 -4
- data/lib/mongoid/criteria/queryable/mergeable.rb +46 -20
- data/lib/mongoid/criteria/queryable/selectable.rb +8 -8
- data/lib/mongoid/criteria.rb +4 -5
- data/lib/mongoid/document.rb +1 -15
- data/lib/mongoid/errors/delete_restriction.rb +8 -9
- data/lib/mongoid/evolvable.rb +1 -1
- data/lib/mongoid/extensions/boolean.rb +1 -2
- data/lib/mongoid/extensions/false_class.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +2 -2
- data/lib/mongoid/extensions/true_class.rb +1 -1
- data/lib/mongoid/fields.rb +43 -5
- data/lib/mongoid/inspectable.rb +1 -1
- data/lib/mongoid/matcher/bits.rb +41 -0
- data/lib/mongoid/matcher/bits_all_clear.rb +20 -0
- data/lib/mongoid/matcher/bits_all_set.rb +20 -0
- data/lib/mongoid/matcher/bits_any_clear.rb +20 -0
- data/lib/mongoid/matcher/bits_any_set.rb +20 -0
- data/lib/mongoid/matcher/expression.rb +4 -0
- data/lib/mongoid/matcher/field_operator.rb +6 -0
- data/lib/mongoid/matcher/mod.rb +17 -0
- data/lib/mongoid/matcher/type.rb +99 -0
- data/lib/mongoid/matcher.rb +7 -0
- data/lib/mongoid/persistable/deletable.rb +1 -2
- data/lib/mongoid/persistable/destroyable.rb +8 -2
- data/lib/mongoid/persistable/updatable.rb +27 -2
- data/lib/mongoid/query_cache.rb +35 -29
- data/lib/mongoid/selectable.rb +5 -7
- data/lib/mongoid/shardable.rb +21 -5
- data/lib/mongoid/touchable.rb +33 -4
- data/lib/mongoid/version.rb +1 -1
- data/spec/integration/associations/embeds_many_spec.rb +44 -0
- data/spec/integration/associations/has_one_spec.rb +48 -0
- data/spec/integration/criteria/date_field_spec.rb +1 -1
- data/spec/integration/document_spec.rb +9 -0
- data/spec/integration/matcher_operator_data/bits_all_clear.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_all_set.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_any_clear.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_any_set.yml +159 -0
- data/spec/integration/matcher_operator_data/comment.yml +22 -0
- data/spec/integration/matcher_operator_data/in.yml +16 -0
- data/spec/integration/matcher_operator_data/mod.yml +55 -0
- data/spec/integration/matcher_operator_data/type.yml +70 -0
- data/spec/integration/matcher_operator_data/type_array.yml +16 -0
- data/spec/integration/matcher_operator_data/type_binary.yml +18 -0
- data/spec/integration/matcher_operator_data/type_boolean.yml +39 -0
- data/spec/integration/matcher_operator_data/type_code.yml +26 -0
- data/spec/integration/matcher_operator_data/type_code_with_scope.yml +26 -0
- data/spec/integration/matcher_operator_data/type_date.yml +39 -0
- data/spec/integration/matcher_operator_data/type_db_pointer.yml +19 -0
- data/spec/integration/matcher_operator_data/type_decimal.yml +40 -0
- data/spec/integration/matcher_operator_data/type_double.yml +15 -0
- data/spec/integration/matcher_operator_data/type_int32.yml +33 -0
- data/spec/integration/matcher_operator_data/type_int64.yml +33 -0
- data/spec/integration/matcher_operator_data/type_max_key.yml +17 -0
- data/spec/integration/matcher_operator_data/type_min_key.yml +17 -0
- data/spec/integration/matcher_operator_data/type_null.yml +23 -0
- data/spec/integration/matcher_operator_data/type_object.yml +23 -0
- data/spec/integration/matcher_operator_data/type_object_id.yml +25 -0
- data/spec/integration/matcher_operator_data/type_regex.yml +44 -0
- data/spec/integration/matcher_operator_data/type_string.yml +15 -0
- data/spec/integration/matcher_operator_data/type_symbol.yml +32 -0
- data/spec/integration/matcher_operator_data/type_timestamp.yml +25 -0
- data/spec/integration/matcher_operator_data/type_undefined.yml +17 -0
- data/spec/lite_spec_helper.rb +2 -0
- data/spec/mongoid/association/depending_spec.rb +391 -352
- data/spec/mongoid/association/nested/one_spec.rb +18 -14
- data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +25 -8
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many/binding_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +245 -93
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +6 -6
- data/spec/mongoid/association/referenced/has_one_models.rb +8 -0
- data/spec/mongoid/atomic/paths_spec.rb +64 -12
- data/spec/mongoid/attributes/projector_data/embedded.yml +105 -0
- data/spec/mongoid/attributes/projector_data/fields.yml +93 -0
- data/spec/mongoid/attributes/projector_spec.rb +41 -0
- data/spec/mongoid/attributes_spec.rb +98 -6
- data/spec/mongoid/clients/factory_spec.rb +48 -0
- data/spec/mongoid/config_spec.rb +106 -1
- data/spec/mongoid/contextual/mongo_spec.rb +2 -2
- data/spec/mongoid/criteria/modifiable_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/expandable_spec.rb +0 -73
- data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/mergeable_spec.rb +105 -7
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +229 -24
- data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +39 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -565
- data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +590 -0
- data/spec/mongoid/criteria_projection_spec.rb +411 -0
- data/spec/mongoid/criteria_spec.rb +0 -275
- data/spec/mongoid/document_spec.rb +13 -13
- data/spec/mongoid/errors/delete_restriction_spec.rb +1 -1
- data/spec/mongoid/extensions/false_class_spec.rb +1 -1
- data/spec/mongoid/extensions/string_spec.rb +5 -5
- data/spec/mongoid/extensions/true_class_spec.rb +1 -1
- data/spec/mongoid/fields/localized_spec.rb +4 -4
- data/spec/mongoid/fields_spec.rb +4 -4
- data/spec/mongoid/inspectable_spec.rb +12 -4
- data/spec/mongoid/persistable/deletable_spec.rb +175 -1
- data/spec/mongoid/persistable/destroyable_spec.rb +191 -3
- data/spec/mongoid/persistable/savable_spec.rb +3 -5
- data/spec/mongoid/persistable/upsertable_spec.rb +1 -1
- data/spec/mongoid/query_cache_middleware_spec.rb +8 -0
- data/spec/mongoid/reloadable_spec.rb +18 -1
- data/spec/mongoid/shardable_spec.rb +44 -0
- data/spec/mongoid/touchable_spec.rb +122 -16
- data/spec/mongoid/touchable_spec_models.rb +54 -0
- data/spec/mongoid/validatable_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -2
- data/spec/support/client_registry.rb +9 -0
- data/spec/support/models/bolt.rb +8 -0
- data/spec/support/models/hole.rb +13 -0
- data/spec/support/models/mop.rb +0 -1
- data/spec/support/models/nut.rb +8 -0
- data/spec/support/models/person.rb +6 -0
- data/spec/support/models/sealer.rb +8 -0
- data/spec/support/models/shirt.rb +12 -0
- data/spec/support/models/spacer.rb +8 -0
- data/spec/support/models/threadlocker.rb +8 -0
- data/spec/support/models/washer.rb +8 -0
- data.tar.gz.sig +0 -0
- metadata +97 -3
- metadata.gz.sig +0 -0
- data/spec/support/cluster_config.rb +0 -158
@@ -137,20 +137,24 @@ describe Mongoid::Association::Nested::One do
|
|
137
137
|
{ allow_destroy: true }
|
138
138
|
end
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
140
|
+
%i(id _id).each do |id_field|
|
141
|
+
context "#{id_field}" do
|
142
|
+
let(:builder) do
|
143
|
+
described_class.new(association, {
|
144
|
+
id_field => name.id,
|
145
|
+
last_name: "Lang",
|
146
|
+
_destroy: true
|
147
|
+
}, options)
|
148
|
+
end
|
149
|
+
|
150
|
+
before do
|
151
|
+
builder.build(person)
|
152
|
+
end
|
153
|
+
|
154
|
+
it "deletes the relation" do
|
155
|
+
expect(person.name).to be_nil
|
156
|
+
end
|
157
|
+
end
|
154
158
|
end
|
155
159
|
end
|
156
160
|
end
|
@@ -127,6 +127,23 @@ describe Mongoid::Association::Referenced::BelongsTo::Proxy do
|
|
127
127
|
it "does not save the target" do
|
128
128
|
expect(person).to_not be_persisted
|
129
129
|
end
|
130
|
+
|
131
|
+
it "drops private visibility from private methods" do
|
132
|
+
# This is unfortunate but it appears that Ruby does not
|
133
|
+
# have a way to distinguish how method_missing was invoked
|
134
|
+
# (i.e. via an explicit send or method call).
|
135
|
+
# See https://jira.mongodb.org/browse/MONGOID-5009
|
136
|
+
game.person.secret_name.should == 'secret'
|
137
|
+
end
|
138
|
+
|
139
|
+
it "allows private methods to be invoked" do
|
140
|
+
game.person.send(:secret_name).should == 'secret'
|
141
|
+
end
|
142
|
+
|
143
|
+
it "properly exposes delegated methods visibility" do
|
144
|
+
expect(defined?(game.person.id)).to eq("method")
|
145
|
+
expect(defined?(game.person.secret_name)).to be_nil
|
146
|
+
end
|
130
147
|
end
|
131
148
|
|
132
149
|
context "when the child is not a new record" do
|
@@ -508,7 +525,7 @@ describe Mongoid::Association::Referenced::BelongsTo::Proxy do
|
|
508
525
|
context "when child is destroyed" do
|
509
526
|
|
510
527
|
before do
|
511
|
-
account.
|
528
|
+
account.destroy
|
512
529
|
end
|
513
530
|
|
514
531
|
it "deletes child" do
|
@@ -548,7 +565,7 @@ describe Mongoid::Association::Referenced::BelongsTo::Proxy do
|
|
548
565
|
context "when child is destroyed" do
|
549
566
|
|
550
567
|
before do
|
551
|
-
drug.
|
568
|
+
drug.destroy
|
552
569
|
end
|
553
570
|
|
554
571
|
it "deletes child" do
|
@@ -600,10 +617,10 @@ describe Mongoid::Association::Referenced::BelongsTo::Proxy do
|
|
600
617
|
|
601
618
|
context "when parent is persisted" do
|
602
619
|
|
603
|
-
context "when child is
|
620
|
+
context "when child is destroyed" do
|
604
621
|
|
605
622
|
before do
|
606
|
-
account.
|
623
|
+
account.destroy
|
607
624
|
end
|
608
625
|
|
609
626
|
it "deletes child" do
|
@@ -643,7 +660,7 @@ describe Mongoid::Association::Referenced::BelongsTo::Proxy do
|
|
643
660
|
context "when child is destroyed" do
|
644
661
|
|
645
662
|
before do
|
646
|
-
drug.
|
663
|
+
drug.destroy
|
647
664
|
end
|
648
665
|
|
649
666
|
it "deletes child" do
|
@@ -690,10 +707,10 @@ describe Mongoid::Association::Referenced::BelongsTo::Proxy do
|
|
690
707
|
|
691
708
|
context "when parent is persisted" do
|
692
709
|
|
693
|
-
context "when child is
|
710
|
+
context "when child is destroyed" do
|
694
711
|
|
695
712
|
before do
|
696
|
-
account.
|
713
|
+
account.destroy
|
697
714
|
end
|
698
715
|
|
699
716
|
it "deletes child" do
|
@@ -732,7 +749,7 @@ describe Mongoid::Association::Referenced::BelongsTo::Proxy do
|
|
732
749
|
context "when child is destroyed" do
|
733
750
|
|
734
751
|
before do
|
735
|
-
drug.
|
752
|
+
drug.destroy
|
736
753
|
end
|
737
754
|
|
738
755
|
it "deletes child" do
|
@@ -14,7 +14,7 @@ describe Mongoid::Association::Referenced::HasAndBelongsToMany::Binding do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
let(:target) do
|
17
|
-
Mongoid::Association::Referenced::HasMany::
|
17
|
+
Mongoid::Association::Referenced::HasMany::Enumerable.new([ preference ])
|
18
18
|
end
|
19
19
|
|
20
20
|
let(:association) do
|
@@ -14,7 +14,7 @@ describe Mongoid::Association::Referenced::HasMany::Binding do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
let(:target) do
|
17
|
-
Mongoid::Association::Referenced::HasMany::
|
17
|
+
Mongoid::Association::Referenced::HasMany::Enumerable.new([ post ])
|
18
18
|
end
|
19
19
|
|
20
20
|
let(:association) do
|
@@ -3,18 +3,18 @@
|
|
3
3
|
|
4
4
|
require "spec_helper"
|
5
5
|
|
6
|
-
describe Mongoid::Association::Referenced::HasMany::
|
6
|
+
describe Mongoid::Association::Referenced::HasMany::Enumerable do
|
7
7
|
|
8
8
|
describe "#==" do
|
9
9
|
|
10
10
|
context "when comparing with an enumerable" do
|
11
11
|
|
12
12
|
let(:person) do
|
13
|
-
Person.create
|
13
|
+
Person.create!
|
14
14
|
end
|
15
15
|
|
16
16
|
let!(:post) do
|
17
|
-
Post.create(person_id: person.id)
|
17
|
+
Post.create!(person_id: person.id)
|
18
18
|
end
|
19
19
|
|
20
20
|
context "when only a criteria target exists" do
|
@@ -88,7 +88,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
88
88
|
context "when the loaded has no docs and added is persisted" do
|
89
89
|
|
90
90
|
before do
|
91
|
-
post.save
|
91
|
+
post.save!
|
92
92
|
enumerable._added[post.id] = post
|
93
93
|
end
|
94
94
|
|
@@ -168,18 +168,18 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
168
168
|
describe "#<<" do
|
169
169
|
|
170
170
|
let(:person) do
|
171
|
-
Person.create
|
171
|
+
Person.create!
|
172
172
|
end
|
173
173
|
|
174
174
|
let!(:post) do
|
175
|
-
Post.create(person_id: person.id)
|
175
|
+
Post.create!(person_id: person.id)
|
176
176
|
end
|
177
177
|
|
178
178
|
let!(:enumerable) do
|
179
179
|
described_class.new([])
|
180
180
|
end
|
181
181
|
|
182
|
-
context "when the
|
182
|
+
context "when the association is empty" do
|
183
183
|
|
184
184
|
let!(:added) do
|
185
185
|
enumerable << post
|
@@ -201,18 +201,18 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
|
-
describe "#
|
204
|
+
describe "#empty?" do
|
205
205
|
|
206
206
|
let(:person) do
|
207
|
-
Person.create
|
207
|
+
Person.create!
|
208
208
|
end
|
209
209
|
|
210
210
|
let!(:post_one) do
|
211
|
-
Post.create(person_id: person.id)
|
211
|
+
Post.create!(person_id: person.id)
|
212
212
|
end
|
213
213
|
|
214
214
|
let!(:post_two) do
|
215
|
-
Post.create(person_id: person.id)
|
215
|
+
Post.create!(person_id: person.id)
|
216
216
|
end
|
217
217
|
|
218
218
|
context "when only a criteria target exists" do
|
@@ -225,28 +225,139 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
225
225
|
described_class.new(criteria)
|
226
226
|
end
|
227
227
|
|
228
|
-
let
|
229
|
-
enumerable.
|
228
|
+
let(:empty) do
|
229
|
+
enumerable.empty?
|
230
230
|
end
|
231
231
|
|
232
|
-
it "returns
|
233
|
-
expect(
|
232
|
+
it "returns false" do
|
233
|
+
expect(empty).to be false
|
234
234
|
end
|
235
235
|
|
236
|
-
|
237
|
-
|
236
|
+
context 'when #empty? is called' do
|
237
|
+
|
238
|
+
before { empty }
|
239
|
+
|
240
|
+
it "retains the correct length" do
|
241
|
+
expect(enumerable.length).to eq(2)
|
242
|
+
end
|
243
|
+
|
244
|
+
it "retains the correct length when calling to_a" do
|
245
|
+
expect(enumerable.to_a.length).to eq(2)
|
246
|
+
end
|
247
|
+
|
248
|
+
context "when iterating over the association a second time" do
|
249
|
+
|
250
|
+
before do
|
251
|
+
enumerable.each { |post| post }
|
252
|
+
end
|
253
|
+
|
254
|
+
it "retains the correct length" do
|
255
|
+
expect(enumerable.length).to eq(2)
|
256
|
+
end
|
257
|
+
|
258
|
+
it "retains the correct length when calling to_a" do
|
259
|
+
expect(enumerable.to_a.length).to eq(2)
|
260
|
+
end
|
261
|
+
end
|
238
262
|
end
|
263
|
+
end
|
239
264
|
|
240
|
-
|
241
|
-
|
265
|
+
context "when the documents have been loaded" do
|
266
|
+
let(:criteria) do
|
267
|
+
Post.where(person_id: person.id)
|
268
|
+
end
|
269
|
+
|
270
|
+
let!(:enumerable) do
|
271
|
+
described_class.new(criteria)
|
272
|
+
end
|
273
|
+
|
274
|
+
before do
|
275
|
+
enumerable.load_all!
|
276
|
+
end
|
277
|
+
|
278
|
+
it "is _loaded" do
|
279
|
+
expect(enumerable._loaded?).to be true
|
280
|
+
end
|
281
|
+
|
282
|
+
it "it does not call #exists? on the unloaded scope" do
|
283
|
+
expect(enumerable._unloaded).to_not receive(:exists?)
|
284
|
+
expect(enumerable.empty?).to be false
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
context "when the documents are not loaded" do
|
289
|
+
|
290
|
+
let(:criteria) do
|
291
|
+
Post.where(person_id: person.id)
|
292
|
+
end
|
293
|
+
|
294
|
+
let!(:enumerable) do
|
295
|
+
described_class.new(criteria)
|
296
|
+
end
|
297
|
+
|
298
|
+
it "is not _loaded" do
|
299
|
+
expect(enumerable._loaded?).to be false
|
300
|
+
end
|
301
|
+
|
302
|
+
it "it calls #exists? on the unloaded scope" do
|
303
|
+
expect(enumerable._unloaded).to receive(:exists?)
|
304
|
+
expect(enumerable.empty?).to be true
|
242
305
|
end
|
243
306
|
|
244
|
-
context "when
|
307
|
+
context "when documents are added" do
|
245
308
|
|
246
309
|
before do
|
247
|
-
enumerable
|
310
|
+
enumerable << post_one
|
311
|
+
end
|
312
|
+
|
313
|
+
it "is not _loaded" do
|
314
|
+
expect(enumerable._loaded?).to be false
|
248
315
|
end
|
249
316
|
|
317
|
+
it "it does not call #exists? on the unloaded scope" do
|
318
|
+
expect(enumerable._unloaded).to_not receive(:exists?)
|
319
|
+
expect(enumerable.empty?).to be false
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
describe "#any?" do
|
326
|
+
|
327
|
+
let(:person) do
|
328
|
+
Person.create!
|
329
|
+
end
|
330
|
+
|
331
|
+
let!(:post_one) do
|
332
|
+
Post.create!(person_id: person.id)
|
333
|
+
end
|
334
|
+
|
335
|
+
let!(:post_two) do
|
336
|
+
Post.create!(person_id: person.id)
|
337
|
+
end
|
338
|
+
|
339
|
+
context "when only a criteria target exists" do
|
340
|
+
|
341
|
+
let(:criteria) do
|
342
|
+
Post.where(person_id: person.id)
|
343
|
+
end
|
344
|
+
|
345
|
+
let!(:enumerable) do
|
346
|
+
described_class.new(criteria)
|
347
|
+
end
|
348
|
+
|
349
|
+
let(:any) do
|
350
|
+
enumerable.any?
|
351
|
+
end
|
352
|
+
|
353
|
+
it "returns true" do
|
354
|
+
expect(any).to be true
|
355
|
+
end
|
356
|
+
|
357
|
+
context 'when #any? is called' do
|
358
|
+
|
359
|
+
before { any }
|
360
|
+
|
250
361
|
it "retains the correct length" do
|
251
362
|
expect(enumerable.length).to eq(2)
|
252
363
|
end
|
@@ -254,6 +365,21 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
254
365
|
it "retains the correct length when calling to_a" do
|
255
366
|
expect(enumerable.to_a.length).to eq(2)
|
256
367
|
end
|
368
|
+
|
369
|
+
context "when iterating over the association a second time" do
|
370
|
+
|
371
|
+
before do
|
372
|
+
enumerable.each { |post| post }
|
373
|
+
end
|
374
|
+
|
375
|
+
it "retains the correct length" do
|
376
|
+
expect(enumerable.length).to eq(2)
|
377
|
+
end
|
378
|
+
|
379
|
+
it "retains the correct length when calling to_a" do
|
380
|
+
expect(enumerable.to_a.length).to eq(2)
|
381
|
+
end
|
382
|
+
end
|
257
383
|
end
|
258
384
|
end
|
259
385
|
|
@@ -274,6 +400,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
274
400
|
expect(enumerable._loaded?).to be true
|
275
401
|
end
|
276
402
|
|
403
|
+
it "it does not call #exists? on the unloaded scope" do
|
404
|
+
expect(enumerable._unloaded).to_not receive(:exists?)
|
405
|
+
expect(enumerable.any?).to be true
|
406
|
+
end
|
407
|
+
|
277
408
|
context "when a block is given" do
|
278
409
|
it "returns true when the predicate is true" do
|
279
410
|
expect(
|
@@ -325,6 +456,27 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
325
456
|
expect(enumerable._loaded?).to be false
|
326
457
|
end
|
327
458
|
|
459
|
+
it "it calls #exists? on the unloaded scope" do
|
460
|
+
expect(enumerable._unloaded).to receive(:exists?)
|
461
|
+
expect(enumerable.any?).to be false
|
462
|
+
end
|
463
|
+
|
464
|
+
context "when documents are added" do
|
465
|
+
|
466
|
+
before do
|
467
|
+
enumerable << post_one
|
468
|
+
end
|
469
|
+
|
470
|
+
it "is not _loaded" do
|
471
|
+
expect(enumerable._loaded?).to be false
|
472
|
+
end
|
473
|
+
|
474
|
+
it "it does not call #exists? on the unloaded scope" do
|
475
|
+
expect(enumerable._unloaded).to_not receive(:exists?)
|
476
|
+
expect(enumerable.any?).to be true
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
328
480
|
context "when a block is given" do
|
329
481
|
it "returns true when the predicate is true" do
|
330
482
|
expect(
|
@@ -366,15 +518,15 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
366
518
|
describe "#clear" do
|
367
519
|
|
368
520
|
let(:person) do
|
369
|
-
Person.create
|
521
|
+
Person.create!
|
370
522
|
end
|
371
523
|
|
372
524
|
let!(:post) do
|
373
|
-
Post.create(person_id: person.id)
|
525
|
+
Post.create!(person_id: person.id)
|
374
526
|
end
|
375
527
|
|
376
528
|
let!(:post_two) do
|
377
|
-
Post.create(person_id: person.id)
|
529
|
+
Post.create!(person_id: person.id)
|
378
530
|
end
|
379
531
|
|
380
532
|
let(:criteria) do
|
@@ -412,15 +564,15 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
412
564
|
describe "#clone" do
|
413
565
|
|
414
566
|
let(:person) do
|
415
|
-
Person.create
|
567
|
+
Person.create!
|
416
568
|
end
|
417
569
|
|
418
570
|
let!(:post) do
|
419
|
-
Post.create(title: "one", person_id: person.id)
|
571
|
+
Post.create!(title: "one", person_id: person.id)
|
420
572
|
end
|
421
573
|
|
422
574
|
let!(:post_two) do
|
423
|
-
Post.create(title: "two", person_id: person.id)
|
575
|
+
Post.create!(title: "two", person_id: person.id)
|
424
576
|
end
|
425
577
|
|
426
578
|
let(:criteria) do
|
@@ -452,13 +604,13 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
452
604
|
describe "#delete" do
|
453
605
|
|
454
606
|
let(:person) do
|
455
|
-
Person.create
|
607
|
+
Person.create!
|
456
608
|
end
|
457
609
|
|
458
610
|
context "when the document is loaded" do
|
459
611
|
|
460
612
|
let!(:post) do
|
461
|
-
Post.create(person_id: person.id)
|
613
|
+
Post.create!(person_id: person.id)
|
462
614
|
end
|
463
615
|
|
464
616
|
let!(:enumerable) do
|
@@ -512,7 +664,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
512
664
|
context "when the document is unloaded" do
|
513
665
|
|
514
666
|
let!(:post) do
|
515
|
-
Post.create(person_id: person.id)
|
667
|
+
Post.create!(person_id: person.id)
|
516
668
|
end
|
517
669
|
|
518
670
|
let(:criteria) do
|
@@ -539,7 +691,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
539
691
|
context "when the document is not found" do
|
540
692
|
|
541
693
|
let!(:post) do
|
542
|
-
Post.create(person_id: person.id)
|
694
|
+
Post.create!(person_id: person.id)
|
543
695
|
end
|
544
696
|
|
545
697
|
let(:criteria) do
|
@@ -565,13 +717,13 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
565
717
|
describe "#delete_if" do
|
566
718
|
|
567
719
|
let(:person) do
|
568
|
-
Person.create
|
720
|
+
Person.create!
|
569
721
|
end
|
570
722
|
|
571
723
|
context "when the document is loaded" do
|
572
724
|
|
573
725
|
let!(:post) do
|
574
|
-
Post.create(person_id: person.id)
|
726
|
+
Post.create!(person_id: person.id)
|
575
727
|
end
|
576
728
|
|
577
729
|
let!(:enumerable) do
|
@@ -625,7 +777,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
625
777
|
context "when the document is unloaded" do
|
626
778
|
|
627
779
|
let!(:post) do
|
628
|
-
Post.create(person_id: person.id)
|
780
|
+
Post.create!(person_id: person.id)
|
629
781
|
end
|
630
782
|
|
631
783
|
let(:criteria) do
|
@@ -652,7 +804,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
652
804
|
context "when the block doesn't match" do
|
653
805
|
|
654
806
|
let!(:post) do
|
655
|
-
Post.create(person_id: person.id)
|
807
|
+
Post.create!(person_id: person.id)
|
656
808
|
end
|
657
809
|
|
658
810
|
let(:criteria) do
|
@@ -676,11 +828,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
676
828
|
describe "#detect" do
|
677
829
|
|
678
830
|
let(:person) do
|
679
|
-
Person.create
|
831
|
+
Person.create!
|
680
832
|
end
|
681
833
|
|
682
834
|
let!(:post) do
|
683
|
-
Post.create(person: person, title: "test")
|
835
|
+
Post.create!(person: person, title: "test")
|
684
836
|
end
|
685
837
|
|
686
838
|
let(:criteria) do
|
@@ -706,11 +858,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
706
858
|
describe "#each" do
|
707
859
|
|
708
860
|
let(:person) do
|
709
|
-
Person.create
|
861
|
+
Person.create!
|
710
862
|
end
|
711
863
|
|
712
864
|
let!(:post) do
|
713
|
-
Post.create(person_id: person.id)
|
865
|
+
Post.create!(person_id: person.id)
|
714
866
|
end
|
715
867
|
|
716
868
|
context "when only a criteria target exists" do
|
@@ -737,18 +889,18 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
737
889
|
expect(enumerable).to be__loaded
|
738
890
|
end
|
739
891
|
|
740
|
-
context 'when the base
|
892
|
+
context 'when the base association is accessed from each document' do
|
741
893
|
|
742
894
|
let(:persons) do
|
743
895
|
described_class.new(criteria).collect(&:person)
|
744
896
|
end
|
745
897
|
|
746
898
|
before do
|
747
|
-
Post.create(person_id: person.id)
|
748
|
-
Post.create(person_id: person.id)
|
899
|
+
Post.create!(person_id: person.id)
|
900
|
+
Post.create!(person_id: person.id)
|
749
901
|
end
|
750
902
|
|
751
|
-
it 'sets the base
|
903
|
+
it 'sets the base association from the criteria' do
|
752
904
|
expect(persons.uniq.size).to eq(1)
|
753
905
|
end
|
754
906
|
end
|
@@ -856,7 +1008,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
856
1008
|
describe "#entries" do
|
857
1009
|
|
858
1010
|
let(:person) do
|
859
|
-
Person.create
|
1011
|
+
Person.create!
|
860
1012
|
end
|
861
1013
|
|
862
1014
|
let(:criteria) do
|
@@ -870,7 +1022,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
870
1022
|
context "when the added contains a persisted document" do
|
871
1023
|
|
872
1024
|
let!(:post) do
|
873
|
-
Post.create(person_id: person.id)
|
1025
|
+
Post.create!(person_id: person.id)
|
874
1026
|
end
|
875
1027
|
|
876
1028
|
before do
|
@@ -890,7 +1042,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
890
1042
|
describe "#first" do
|
891
1043
|
|
892
1044
|
let(:person) do
|
893
|
-
Person.create
|
1045
|
+
Person.create!
|
894
1046
|
end
|
895
1047
|
|
896
1048
|
context "when the enumerable is not loaded" do
|
@@ -908,7 +1060,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
908
1060
|
context "when added is empty" do
|
909
1061
|
|
910
1062
|
let!(:post) do
|
911
|
-
Post.create(person_id: person.id)
|
1063
|
+
Post.create!(person_id: person.id)
|
912
1064
|
end
|
913
1065
|
|
914
1066
|
let(:first) do
|
@@ -932,7 +1084,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
932
1084
|
context "when added is not empty" do
|
933
1085
|
|
934
1086
|
let!(:post) do
|
935
|
-
Post.create(person_id: person.id)
|
1087
|
+
Post.create!(person_id: person.id)
|
936
1088
|
end
|
937
1089
|
|
938
1090
|
let(:post_two) do
|
@@ -1004,7 +1156,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1004
1156
|
context "when loaded is not empty" do
|
1005
1157
|
|
1006
1158
|
let!(:post) do
|
1007
|
-
Post.create(person_id: person.id)
|
1159
|
+
Post.create!(person_id: person.id)
|
1008
1160
|
end
|
1009
1161
|
|
1010
1162
|
let(:enumerable) do
|
@@ -1023,7 +1175,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1023
1175
|
context "when loaded is empty" do
|
1024
1176
|
|
1025
1177
|
let!(:post) do
|
1026
|
-
Post.create(person_id: person.id)
|
1178
|
+
Post.create!(person_id: person.id)
|
1027
1179
|
end
|
1028
1180
|
|
1029
1181
|
let(:enumerable) do
|
@@ -1062,7 +1214,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1062
1214
|
context 'when the id_sort option is none' do
|
1063
1215
|
|
1064
1216
|
let(:person) do
|
1065
|
-
Person.create
|
1217
|
+
Person.create!
|
1066
1218
|
end
|
1067
1219
|
|
1068
1220
|
let(:criteria) do
|
@@ -1074,11 +1226,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1074
1226
|
end
|
1075
1227
|
|
1076
1228
|
let!(:first_post) do
|
1077
|
-
person.posts.create(title: "One")
|
1229
|
+
person.posts.create!(title: "One")
|
1078
1230
|
end
|
1079
1231
|
|
1080
1232
|
let!(:second_post) do
|
1081
|
-
person.posts.create(title: "Two")
|
1233
|
+
person.posts.create!(title: "Two")
|
1082
1234
|
end
|
1083
1235
|
|
1084
1236
|
it 'does not use the sort on id' do
|
@@ -1089,7 +1241,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1089
1241
|
context 'when the id_sort option is not provided' do
|
1090
1242
|
|
1091
1243
|
let(:person) do
|
1092
|
-
Person.create
|
1244
|
+
Person.create!
|
1093
1245
|
end
|
1094
1246
|
|
1095
1247
|
let(:criteria) do
|
@@ -1101,11 +1253,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1101
1253
|
end
|
1102
1254
|
|
1103
1255
|
let!(:first_post) do
|
1104
|
-
person.posts.create(title: "One")
|
1256
|
+
person.posts.create!(title: "One")
|
1105
1257
|
end
|
1106
1258
|
|
1107
1259
|
let!(:second_post) do
|
1108
|
-
person.posts.create(title: "Two")
|
1260
|
+
person.posts.create!(title: "Two")
|
1109
1261
|
end
|
1110
1262
|
|
1111
1263
|
it 'uses the sort on id' do
|
@@ -1117,15 +1269,15 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1117
1269
|
describe "#include?" do
|
1118
1270
|
|
1119
1271
|
let(:person) do
|
1120
|
-
Person.create
|
1272
|
+
Person.create!
|
1121
1273
|
end
|
1122
1274
|
|
1123
1275
|
let!(:post_one) do
|
1124
|
-
Post.create(person_id: person.id)
|
1276
|
+
Post.create!(person_id: person.id)
|
1125
1277
|
end
|
1126
1278
|
|
1127
1279
|
let!(:post_two) do
|
1128
|
-
Post.create(person_id: person.id)
|
1280
|
+
Post.create!(person_id: person.id)
|
1129
1281
|
end
|
1130
1282
|
|
1131
1283
|
context "when no criteria exists" do
|
@@ -1187,7 +1339,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1187
1339
|
described_class.new(criteria)
|
1188
1340
|
end
|
1189
1341
|
|
1190
|
-
let
|
1342
|
+
let(:included) do
|
1191
1343
|
enumerable.include?(post_two)
|
1192
1344
|
end
|
1193
1345
|
|
@@ -1203,7 +1355,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1203
1355
|
expect(enumerable.to_a.length).to eq(2)
|
1204
1356
|
end
|
1205
1357
|
|
1206
|
-
context "when iterating over the
|
1358
|
+
context "when iterating over the association a second time" do
|
1207
1359
|
|
1208
1360
|
before do
|
1209
1361
|
enumerable.each { |post| post }
|
@@ -1371,7 +1523,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1371
1523
|
describe "#last" do
|
1372
1524
|
|
1373
1525
|
let(:person) do
|
1374
|
-
Person.create
|
1526
|
+
Person.create!
|
1375
1527
|
end
|
1376
1528
|
|
1377
1529
|
context "when the enumerable is not loaded" do
|
@@ -1387,7 +1539,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1387
1539
|
context "when unloaded is not empty" do
|
1388
1540
|
|
1389
1541
|
let!(:post) do
|
1390
|
-
Post.create(person_id: person.id)
|
1542
|
+
Post.create!(person_id: person.id)
|
1391
1543
|
end
|
1392
1544
|
|
1393
1545
|
let(:last) do
|
@@ -1449,11 +1601,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1449
1601
|
context "when added is not empty" do
|
1450
1602
|
|
1451
1603
|
let!(:post_one) do
|
1452
|
-
person.posts.create
|
1604
|
+
person.posts.create!
|
1453
1605
|
end
|
1454
1606
|
|
1455
1607
|
let!(:post_two) do
|
1456
|
-
person.posts.create
|
1608
|
+
person.posts.create!
|
1457
1609
|
end
|
1458
1610
|
|
1459
1611
|
let(:last) do
|
@@ -1474,7 +1626,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1474
1626
|
context "when loaded is not empty" do
|
1475
1627
|
|
1476
1628
|
let!(:post) do
|
1477
|
-
Post.create(person_id: person.id)
|
1629
|
+
Post.create!(person_id: person.id)
|
1478
1630
|
end
|
1479
1631
|
|
1480
1632
|
let(:enumerable) do
|
@@ -1493,7 +1645,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1493
1645
|
context "when loaded is empty" do
|
1494
1646
|
|
1495
1647
|
let!(:post) do
|
1496
|
-
Post.create(person_id: person.id)
|
1648
|
+
Post.create!(person_id: person.id)
|
1497
1649
|
end
|
1498
1650
|
|
1499
1651
|
let(:enumerable) do
|
@@ -1532,7 +1684,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1532
1684
|
context 'when the id_sort option is none' do
|
1533
1685
|
|
1534
1686
|
let(:person) do
|
1535
|
-
Person.create
|
1687
|
+
Person.create!
|
1536
1688
|
end
|
1537
1689
|
|
1538
1690
|
let(:criteria) do
|
@@ -1544,11 +1696,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1544
1696
|
end
|
1545
1697
|
|
1546
1698
|
let!(:first_post) do
|
1547
|
-
person.posts.create(title: "One")
|
1699
|
+
person.posts.create!(title: "One")
|
1548
1700
|
end
|
1549
1701
|
|
1550
1702
|
let!(:second_post) do
|
1551
|
-
person.posts.create(title: "Two")
|
1703
|
+
person.posts.create!(title: "Two")
|
1552
1704
|
end
|
1553
1705
|
|
1554
1706
|
it 'does not use the sort on id' do
|
@@ -1559,7 +1711,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1559
1711
|
context 'when the id_sort option is not provided' do
|
1560
1712
|
|
1561
1713
|
let(:person) do
|
1562
|
-
Person.create
|
1714
|
+
Person.create!
|
1563
1715
|
end
|
1564
1716
|
|
1565
1717
|
let(:criteria) do
|
@@ -1571,11 +1723,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1571
1723
|
end
|
1572
1724
|
|
1573
1725
|
let!(:first_post) do
|
1574
|
-
person.posts.create(title: "One")
|
1726
|
+
person.posts.create!(title: "One")
|
1575
1727
|
end
|
1576
1728
|
|
1577
1729
|
let!(:second_post) do
|
1578
|
-
person.posts.create(title: "Two")
|
1730
|
+
person.posts.create!(title: "Two")
|
1579
1731
|
end
|
1580
1732
|
|
1581
1733
|
it 'uses the sort on id' do
|
@@ -1608,11 +1760,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1608
1760
|
describe "#load_all!" do
|
1609
1761
|
|
1610
1762
|
let(:person) do
|
1611
|
-
Person.create
|
1763
|
+
Person.create!
|
1612
1764
|
end
|
1613
1765
|
|
1614
1766
|
let!(:post) do
|
1615
|
-
Post.create(person_id: person.id)
|
1767
|
+
Post.create!(person_id: person.id)
|
1616
1768
|
end
|
1617
1769
|
|
1618
1770
|
let(:criteria) do
|
@@ -1643,15 +1795,15 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1643
1795
|
describe "#reset" do
|
1644
1796
|
|
1645
1797
|
let(:person) do
|
1646
|
-
Person.create
|
1798
|
+
Person.create!
|
1647
1799
|
end
|
1648
1800
|
|
1649
1801
|
let(:post) do
|
1650
|
-
Post.create(person_id: person.id)
|
1802
|
+
Post.create!(person_id: person.id)
|
1651
1803
|
end
|
1652
1804
|
|
1653
1805
|
let(:post_two) do
|
1654
|
-
Post.create(person_id: person.id)
|
1806
|
+
Post.create!(person_id: person.id)
|
1655
1807
|
end
|
1656
1808
|
|
1657
1809
|
let(:enumerable) do
|
@@ -1699,11 +1851,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1699
1851
|
describe "#size" do
|
1700
1852
|
|
1701
1853
|
let(:person) do
|
1702
|
-
Person.create
|
1854
|
+
Person.create!
|
1703
1855
|
end
|
1704
1856
|
|
1705
1857
|
let!(:post) do
|
1706
|
-
Post.create(person_id: person.id)
|
1858
|
+
Post.create!(person_id: person.id)
|
1707
1859
|
end
|
1708
1860
|
|
1709
1861
|
context "when the base is new" do
|
@@ -1715,7 +1867,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1715
1867
|
context "when the added contains a persisted document" do
|
1716
1868
|
|
1717
1869
|
let!(:post) do
|
1718
|
-
Post.create(person_id: person.id)
|
1870
|
+
Post.create!(person_id: person.id)
|
1719
1871
|
end
|
1720
1872
|
|
1721
1873
|
context "when the enumerable is not loaded" do
|
@@ -1786,7 +1938,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1786
1938
|
context "when the added contains persisted documents" do
|
1787
1939
|
|
1788
1940
|
let(:post_two) do
|
1789
|
-
Post.create(person_id: person.id)
|
1941
|
+
Post.create!(person_id: person.id)
|
1790
1942
|
end
|
1791
1943
|
|
1792
1944
|
before do
|
@@ -1807,11 +1959,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1807
1959
|
describe "#to_json" do
|
1808
1960
|
|
1809
1961
|
let(:person) do
|
1810
|
-
Person.create
|
1962
|
+
Person.create!
|
1811
1963
|
end
|
1812
1964
|
|
1813
1965
|
let!(:post) do
|
1814
|
-
Post.create(title: "test", person_id: person.id)
|
1966
|
+
Post.create!(title: "test", person_id: person.id)
|
1815
1967
|
end
|
1816
1968
|
|
1817
1969
|
let(:criteria) do
|
@@ -1838,11 +1990,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1838
1990
|
describe "#to_json(parameters)" do
|
1839
1991
|
|
1840
1992
|
let(:person) do
|
1841
|
-
Person.create
|
1993
|
+
Person.create!
|
1842
1994
|
end
|
1843
1995
|
|
1844
1996
|
let!(:post) do
|
1845
|
-
Post.create(title: "test", person_id: person.id)
|
1997
|
+
Post.create!(title: "test", person_id: person.id)
|
1846
1998
|
end
|
1847
1999
|
|
1848
2000
|
let(:criteria) do
|
@@ -1861,11 +2013,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1861
2013
|
describe "#as_json" do
|
1862
2014
|
|
1863
2015
|
let(:person) do
|
1864
|
-
Person.create
|
2016
|
+
Person.create!
|
1865
2017
|
end
|
1866
2018
|
|
1867
2019
|
let!(:post) do
|
1868
|
-
Post.create(title: "test", person_id: person.id)
|
2020
|
+
Post.create!(title: "test", person_id: person.id)
|
1869
2021
|
end
|
1870
2022
|
|
1871
2023
|
let(:criteria) do
|
@@ -1893,11 +2045,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1893
2045
|
describe "#as_json(parameters)" do
|
1894
2046
|
|
1895
2047
|
let(:person) do
|
1896
|
-
Person.create
|
2048
|
+
Person.create!
|
1897
2049
|
end
|
1898
2050
|
|
1899
2051
|
let!(:post) do
|
1900
|
-
Post.create(title: "test", person_id: person.id)
|
2052
|
+
Post.create!(title: "test", person_id: person.id)
|
1901
2053
|
end
|
1902
2054
|
|
1903
2055
|
let(:criteria) do
|
@@ -1920,11 +2072,11 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1920
2072
|
describe "#uniq" do
|
1921
2073
|
|
1922
2074
|
let(:person) do
|
1923
|
-
Person.create
|
2075
|
+
Person.create!
|
1924
2076
|
end
|
1925
2077
|
|
1926
2078
|
let!(:post) do
|
1927
|
-
Post.create(person_id: person.id)
|
2079
|
+
Post.create!(person_id: person.id)
|
1928
2080
|
end
|
1929
2081
|
|
1930
2082
|
let(:criteria) do
|
@@ -1956,7 +2108,7 @@ describe Mongoid::Association::Referenced::HasMany::Targets::Enumerable do
|
|
1956
2108
|
describe 'setting the same parent object on enumerated children objects' do
|
1957
2109
|
|
1958
2110
|
let(:person) do
|
1959
|
-
Person.create
|
2111
|
+
Person.create!
|
1960
2112
|
end
|
1961
2113
|
|
1962
2114
|
context 'when a single child is fetched' do
|