mongoid 7.3.2 → 7.3.3

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/config/locales/en.yml +13 -0
  4. data/lib/mongoid/association/referenced/has_many/enumerable.rb +3 -7
  5. data/lib/mongoid/association/relatable.rb +2 -0
  6. data/lib/mongoid/atomic.rb +26 -2
  7. data/lib/mongoid/config/environment.rb +9 -1
  8. data/lib/mongoid/contextual/atomic.rb +7 -2
  9. data/lib/mongoid/contextual/none.rb +3 -0
  10. data/lib/mongoid/criteria/queryable/selectable.rb +2 -2
  11. data/lib/mongoid/criteria/queryable/storable.rb +4 -4
  12. data/lib/mongoid/document.rb +3 -2
  13. data/lib/mongoid/errors/empty_config_file.rb +26 -0
  14. data/lib/mongoid/errors/invalid_config_file.rb +26 -0
  15. data/lib/mongoid/errors.rb +2 -0
  16. data/lib/mongoid/persistence_context.rb +3 -1
  17. data/lib/mongoid/query_cache.rb +11 -1
  18. data/lib/mongoid/tasks/database.rb +1 -1
  19. data/lib/mongoid/touchable.rb +10 -0
  20. data/lib/mongoid/version.rb +1 -1
  21. data/spec/integration/contextual/empty_spec.rb +142 -0
  22. data/spec/integration/stringified_symbol_field_spec.rb +2 -2
  23. data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +20 -0
  24. data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +244 -92
  25. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +6 -6
  26. data/spec/mongoid/association/referenced/has_many_models.rb +17 -0
  27. data/spec/mongoid/clients/factory_spec.rb +9 -3
  28. data/spec/mongoid/clients/options_spec.rb +11 -5
  29. data/spec/mongoid/config/environment_spec.rb +86 -8
  30. data/spec/mongoid/config_spec.rb +89 -16
  31. data/spec/mongoid/contextual/atomic_spec.rb +64 -25
  32. data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
  33. data/spec/mongoid/document_spec.rb +21 -1
  34. data/spec/mongoid/errors/invalid_config_file_spec.rb +32 -0
  35. data/spec/mongoid/persistable/updatable_spec.rb +2 -0
  36. data/spec/mongoid/query_cache_spec.rb +24 -0
  37. data/spec/mongoid/touchable_spec.rb +18 -0
  38. data/spec/mongoid/touchable_spec_models.rb +2 -0
  39. data/spec/shared/lib/mrss/constraints.rb +21 -4
  40. data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
  41. data/spec/shared/lib/mrss/server_version_registry.rb +17 -12
  42. data/spec/shared/share/Dockerfile.erb +5 -4
  43. data/spec/shared/shlib/server.sh +71 -21
  44. data.tar.gz.sig +0 -0
  45. metadata +581 -573
  46. metadata.gz.sig +0 -0
@@ -31,8 +31,8 @@ describe "StringifiedSymbol fields" do
31
31
  end
32
32
  end
33
33
 
34
- # Using command monitoring to test that StringifiedSymbol sends a string and returns a symbol
35
- let(:client) { Order.collection.client }
34
+ # Using command monitoring to test that StringifiedSymbol sends a string and returns a symbol
35
+ let(:client) { Order.collection.client }
36
36
 
37
37
  before do
38
38
  client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
@@ -35,4 +35,24 @@ describe Mongoid::Association::Referenced::BelongsTo do
35
35
  expect(school.team).to eq('Bulldogs')
36
36
  end
37
37
  end
38
+
39
+ context 'when projecting with #only while having similar inverse_of candidates' do
40
+ before do
41
+ alice = HmmOwner.create!(name: 'Alice')
42
+ bob = HmmOwner.create!(name: 'Bob')
43
+
44
+ HmmPet.create!(name: 'Rex', current_owner: bob, previous_owner: alice)
45
+ end
46
+
47
+ let(:pet) { HmmPet.where(name: 'Rex').only(:name, :previous_owner_id, 'previous_owner.name').first }
48
+
49
+ it 'populates specified fields' do
50
+ expect(pet.name).to eq('Rex')
51
+ expect(pet.previous_owner.name).to eq('Alice')
52
+ end
53
+
54
+ it 'does not try to load the inverse for an association that explicitly prevents it' do
55
+ expect { pet.previous_owner.name }.not_to raise_error
56
+ end
57
+ end
38
58
  end
@@ -10,11 +10,11 @@ describe Mongoid::Association::Referenced::HasMany::Enumerable do
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::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::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 relation is empty" do
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::Enumerable do
201
201
  end
202
202
  end
203
203
 
204
- describe "#any?" do
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::Enumerable do
225
225
  described_class.new(criteria)
226
226
  end
227
227
 
228
- let!(:any) do
229
- enumerable.any?
228
+ let(:empty) do
229
+ enumerable.empty?
230
230
  end
231
231
 
232
- it "returns true" do
233
- expect(any).to be true
232
+ it "returns false" do
233
+ expect(empty).to be false
234
234
  end
235
235
 
236
- it "retains the correct length" do
237
- expect(enumerable.length).to eq(2)
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
- it "retains the correct length when calling to_a" do
241
- expect(enumerable.to_a.length).to eq(2)
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 iterating over the relation a second time" do
307
+ context "when documents are added" do
245
308
 
246
309
  before do
247
- enumerable.each { |post| post }
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::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::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::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::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::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::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::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::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::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::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::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::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::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::Enumerable do
737
889
  expect(enumerable).to be__loaded
738
890
  end
739
891
 
740
- context 'when the base relation is accessed from each document' do
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 relation from the criteria' do
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::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::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::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::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::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::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::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::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::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::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::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::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::Enumerable do
1187
1339
  described_class.new(criteria)
1188
1340
  end
1189
1341
 
1190
- let!(:included) do
1342
+ let(:included) do
1191
1343
  enumerable.include?(post_two)
1192
1344
  end
1193
1345
 
@@ -1203,7 +1355,7 @@ describe Mongoid::Association::Referenced::HasMany::Enumerable do
1203
1355
  expect(enumerable.to_a.length).to eq(2)
1204
1356
  end
1205
1357
 
1206
- context "when iterating over the relation a second time" do
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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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::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