mongoid 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -0
  4. data/CHANGELOG.md +54 -2
  5. data/lib/config/locales/en.yml +1 -1
  6. data/lib/mongoid/attributes.rb +1 -1
  7. data/lib/mongoid/clients.rb +7 -4
  8. data/lib/mongoid/clients/options.rb +2 -2
  9. data/lib/mongoid/contextual/aggregable/mongo.rb +2 -1
  10. data/lib/mongoid/contextual/geo_near.rb +1 -1
  11. data/lib/mongoid/contextual/memory.rb +4 -1
  12. data/lib/mongoid/contextual/mongo.rb +4 -5
  13. data/lib/mongoid/document.rb +1 -0
  14. data/lib/mongoid/indexable/specification.rb +3 -5
  15. data/lib/mongoid/indexable/validators/options.rb +7 -1
  16. data/lib/mongoid/matchable/exists.rb +1 -1
  17. data/lib/mongoid/persistable.rb +2 -1
  18. data/lib/mongoid/persistable/creatable.rb +1 -1
  19. data/lib/mongoid/persistable/deletable.rb +1 -1
  20. data/lib/mongoid/persistable/updatable.rb +2 -2
  21. data/lib/mongoid/positional.rb +75 -0
  22. data/lib/mongoid/relations/counter_cache.rb +19 -0
  23. data/lib/mongoid/relations/eager/base.rb +4 -2
  24. data/lib/mongoid/relations/embedded/batchable.rb +10 -3
  25. data/lib/mongoid/relations/proxy.rb +1 -1
  26. data/lib/mongoid/relations/touchable.rb +1 -1
  27. data/lib/mongoid/scopable.rb +6 -5
  28. data/lib/mongoid/selectable.rb +36 -1
  29. data/lib/mongoid/threaded.rb +34 -2
  30. data/lib/mongoid/timestamps/created.rb +1 -2
  31. data/lib/mongoid/timestamps/timeless.rb +19 -2
  32. data/lib/mongoid/timestamps/updated.rb +1 -1
  33. data/lib/mongoid/traversable.rb +1 -1
  34. data/lib/mongoid/version.rb +1 -1
  35. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +3 -1
  36. data/spec/app/models/account.rb +8 -0
  37. data/spec/app/models/answer.rb +2 -0
  38. data/spec/app/models/article.rb +2 -0
  39. data/spec/app/models/author.rb +2 -0
  40. data/spec/app/models/baby.rb +4 -0
  41. data/spec/app/models/book.rb +2 -0
  42. data/spec/app/models/consumption_period.rb +7 -0
  43. data/spec/app/models/exhibitor.rb +1 -0
  44. data/spec/app/models/kaleidoscope.rb +6 -0
  45. data/spec/app/models/kangaroo.rb +4 -0
  46. data/spec/app/models/note.rb +3 -0
  47. data/spec/app/models/page.rb +11 -0
  48. data/spec/app/models/simple.rb +5 -0
  49. data/spec/config/mongoid.yml +3 -1
  50. data/spec/mongoid/atomic/paths_spec.rb +17 -10
  51. data/spec/mongoid/attributes_spec.rb +2 -2
  52. data/spec/mongoid/clients/options_spec.rb +15 -0
  53. data/spec/mongoid/clients_spec.rb +6 -2
  54. data/spec/mongoid/config_spec.rb +3 -2
  55. data/spec/mongoid/contextual/aggregable/mongo_spec.rb +25 -2
  56. data/spec/mongoid/contextual/atomic_spec.rb +6 -6
  57. data/spec/mongoid/contextual/mongo_spec.rb +28 -75
  58. data/spec/mongoid/criteria_spec.rb +54 -0
  59. data/spec/mongoid/fields/standard_spec.rb +1 -1
  60. data/spec/mongoid/fields_spec.rb +1 -1
  61. data/spec/mongoid/indexable/specification_spec.rb +1 -1
  62. data/spec/mongoid/indexable_spec.rb +7 -7
  63. data/spec/mongoid/interceptable_spec.rb +55 -0
  64. data/spec/mongoid/persistable/creatable_spec.rb +19 -0
  65. data/spec/mongoid/persistable/destroyable_spec.rb +50 -0
  66. data/spec/mongoid/persistable/incrementable_spec.rb +56 -4
  67. data/spec/mongoid/persistable/pushable_spec.rb +11 -0
  68. data/spec/mongoid/persistable/savable_spec.rb +20 -2
  69. data/spec/mongoid/positional_spec.rb +221 -0
  70. data/spec/mongoid/query_cache_spec.rb +19 -0
  71. data/spec/mongoid/relations/auto_save_spec.rb +1 -1
  72. data/spec/mongoid/relations/bindings/referenced/many_to_many_spec.rb +1 -1
  73. data/spec/mongoid/relations/counter_cache_spec.rb +64 -11
  74. data/spec/mongoid/relations/eager/has_many_spec.rb +37 -0
  75. data/spec/mongoid/relations/eager_spec.rb +11 -0
  76. data/spec/mongoid/relations/embedded/many_spec.rb +38 -9
  77. data/spec/mongoid/relations/embedded/one_spec.rb +1 -1
  78. data/spec/mongoid/relations/proxy_spec.rb +22 -0
  79. data/spec/mongoid/relations/reflections_spec.rb +1 -1
  80. data/spec/mongoid/scopable_spec.rb +160 -19
  81. data/spec/mongoid/selectable_spec.rb +16 -6
  82. data/spec/mongoid/timestamps/timeless_spec.rb +17 -0
  83. data/spec/mongoid/validatable/uniqueness_spec.rb +17 -0
  84. metadata +40 -5
  85. metadata.gz.sig +3 -0
@@ -82,8 +82,10 @@ describe Mongoid::Selectable do
82
82
  person.create_name(first_name: "test", last_name: "user")
83
83
  end
84
84
 
85
- it "returns the hash with the root selector" do
86
- expect(name.atomic_selector).to eq({ "_id" => person.id })
85
+ it "returns the hash with the selector" do
86
+ expect(name.atomic_selector).to eq(
87
+ { "_id" => person.id, "name._id" => name.id }
88
+ )
87
89
  end
88
90
  end
89
91
 
@@ -93,8 +95,10 @@ describe Mongoid::Selectable do
93
95
  person.addresses.create(street: "kreuzbergstr")
94
96
  end
95
97
 
96
- it "returns the hash with the root selector" do
97
- expect(address.atomic_selector).to eq({ "_id" => person.id })
98
+ it "returns the hash with the selector" do
99
+ expect(address.atomic_selector).to eq(
100
+ { "_id" => person.id, "addresses._id" => address.id }
101
+ )
98
102
  end
99
103
 
100
104
  context "when the document's id changes" do
@@ -114,8 +118,14 @@ describe Mongoid::Selectable do
114
118
  address.locations.create
115
119
  end
116
120
 
117
- it "returns a hash with the root selector" do
118
- expect(location.atomic_selector).to eq({ "_id" => person.id })
121
+ it "returns a hash with the selector" do
122
+ expect(location.atomic_selector).to eq(
123
+ {
124
+ "_id" => person.id,
125
+ "addresses._id" => address.id,
126
+ "addresses.0.locations._id" => location.id
127
+ }
128
+ )
119
129
  end
120
130
  end
121
131
  end
@@ -27,6 +27,23 @@ describe Mongoid::Timestamps::Timeless do
27
27
  Object.send(:remove_const, :Egg)
28
28
  end
29
29
 
30
+ context "when timeless is used on one instance and then not used on another instance" do
31
+
32
+ let!(:first_instance) do
33
+ egg = Egg.create!
34
+ egg.timeless.save!
35
+ egg
36
+ end
37
+
38
+ let!(:second_instance) do
39
+ Egg.create!
40
+ end
41
+
42
+ it "second instance's created_at is not nil" do
43
+ expect(second_instance.created_at).to_not be_nil
44
+ end
45
+ end
46
+
30
47
  context "when others persist in the scope of the chain" do
31
48
 
32
49
  context "when the root executes normally" do
@@ -789,6 +789,23 @@ describe Mongoid::Validatable::UniquenessValidator do
789
789
  end
790
790
  end
791
791
 
792
+ context "when a range scope is provided" do
793
+
794
+ before do
795
+ Dictionary.validates_uniqueness_of(:name, :scope => Dictionary.where(:year.gte => 1900, :year.lt => 2000))
796
+ Dictionary.create(name: "French-English", year: 1950)
797
+ Dictionary.create(name: "French-English", year: 1960)
798
+ end
799
+
800
+ after do
801
+ Dictionary.reset_callbacks(:validate)
802
+ end
803
+
804
+ it "successfully prevents uniqueness violation" do
805
+ expect(Dictionary.all.size).to eq(1)
806
+ end
807
+ end
808
+
792
809
  context "when multiple scopes are provided" do
793
810
 
794
811
  before do
metadata CHANGED
@@ -1,14 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2015-09-11 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDfDCCAmSgAwIBAgIBATANBgkqhkiG9w0BAQUFADBCMRQwEgYDVQQDDAtkcml2
14
+ ZXItcnVieTEVMBMGCgmSJomT8ixkARkWBTEwZ2VuMRMwEQYKCZImiZPyLGQBGRYD
15
+ Y29tMB4XDTE1MTEw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3XDawWu8kaGtu8giHXcwL3941m8hvFZ/Wr9Yi
31
+ JvcXJt2a4/JvwnIs2hmKuyfhZmB9HEE5wQQaCMnnC14=
32
+ -----END CERTIFICATE-----
33
+ date: 2015-11-03 00:00:00.000000000 Z
12
34
  dependencies:
13
35
  - !ruby/object:Gem::Dependency
14
36
  name: activemodel
@@ -69,7 +91,7 @@ dependencies:
69
91
  description: Mongoid is an ODM (Object Document Mapper) Framework for MongoDB, written
70
92
  in Ruby.
71
93
  email:
72
- - durran@gmail.com
94
+ - mongodb-dev@googlegroups.com
73
95
  executables: []
74
96
  extensions: []
75
97
  extra_rdoc_files: []
@@ -238,6 +260,7 @@ files:
238
260
  - lib/mongoid/persistable/unsettable.rb
239
261
  - lib/mongoid/persistable/updatable.rb
240
262
  - lib/mongoid/persistable/upsertable.rb
263
+ - lib/mongoid/positional.rb
241
264
  - lib/mongoid/query_cache.rb
242
265
  - lib/mongoid/railtie.rb
243
266
  - lib/mongoid/railties/database.rake
@@ -357,6 +380,7 @@ files:
357
380
  - spec/app/models/audio.rb
358
381
  - spec/app/models/augmentation.rb
359
382
  - spec/app/models/author.rb
383
+ - spec/app/models/baby.rb
360
384
  - spec/app/models/band.rb
361
385
  - spec/app/models/bar.rb
362
386
  - spec/app/models/basic.rb
@@ -384,6 +408,7 @@ files:
384
408
  - spec/app/models/code.rb
385
409
  - spec/app/models/comment.rb
386
410
  - spec/app/models/company.rb
411
+ - spec/app/models/consumption_period.rb
387
412
  - spec/app/models/contextable_item.rb
388
413
  - spec/app/models/contractor.rb
389
414
  - spec/app/models/cookie.rb
@@ -430,6 +455,8 @@ files:
430
455
  - spec/app/models/implant.rb
431
456
  - spec/app/models/item.rb
432
457
  - spec/app/models/jar.rb
458
+ - spec/app/models/kaleidoscope.rb
459
+ - spec/app/models/kangaroo.rb
433
460
  - spec/app/models/label.rb
434
461
  - spec/app/models/language.rb
435
462
  - spec/app/models/lat_lng.rb
@@ -500,6 +527,7 @@ files:
500
527
  - spec/app/models/shop.rb
501
528
  - spec/app/models/short_agent.rb
502
529
  - spec/app/models/short_quiz.rb
530
+ - spec/app/models/simple.rb
503
531
  - spec/app/models/slave.rb
504
532
  - spec/app/models/song.rb
505
533
  - spec/app/models/sound.rb
@@ -676,6 +704,7 @@ files:
676
704
  - spec/mongoid/persistable/updatable_spec.rb
677
705
  - spec/mongoid/persistable/upsertable_spec.rb
678
706
  - spec/mongoid/persistable_spec.rb
707
+ - spec/mongoid/positional_spec.rb
679
708
  - spec/mongoid/query_cache_spec.rb
680
709
  - spec/mongoid/railties/document_spec.rb
681
710
  - spec/mongoid/relations/accessors_spec.rb
@@ -780,7 +809,7 @@ rubyforge_project: mongoid
780
809
  rubygems_version: 2.4.6
781
810
  signing_key:
782
811
  specification_version: 4
783
- summary: Elegant Persistance in Ruby for MongoDB.
812
+ summary: Elegant Persistence in Ruby for MongoDB.
784
813
  test_files:
785
814
  - spec/app/models/account.rb
786
815
  - spec/app/models/acolyte.rb
@@ -802,6 +831,7 @@ test_files:
802
831
  - spec/app/models/audio.rb
803
832
  - spec/app/models/augmentation.rb
804
833
  - spec/app/models/author.rb
834
+ - spec/app/models/baby.rb
805
835
  - spec/app/models/band.rb
806
836
  - spec/app/models/bar.rb
807
837
  - spec/app/models/basic.rb
@@ -829,6 +859,7 @@ test_files:
829
859
  - spec/app/models/code.rb
830
860
  - spec/app/models/comment.rb
831
861
  - spec/app/models/company.rb
862
+ - spec/app/models/consumption_period.rb
832
863
  - spec/app/models/contextable_item.rb
833
864
  - spec/app/models/contractor.rb
834
865
  - spec/app/models/cookie.rb
@@ -875,6 +906,8 @@ test_files:
875
906
  - spec/app/models/implant.rb
876
907
  - spec/app/models/item.rb
877
908
  - spec/app/models/jar.rb
909
+ - spec/app/models/kaleidoscope.rb
910
+ - spec/app/models/kangaroo.rb
878
911
  - spec/app/models/label.rb
879
912
  - spec/app/models/language.rb
880
913
  - spec/app/models/lat_lng.rb
@@ -945,6 +978,7 @@ test_files:
945
978
  - spec/app/models/shop.rb
946
979
  - spec/app/models/short_agent.rb
947
980
  - spec/app/models/short_quiz.rb
981
+ - spec/app/models/simple.rb
948
982
  - spec/app/models/slave.rb
949
983
  - spec/app/models/song.rb
950
984
  - spec/app/models/sound.rb
@@ -1121,6 +1155,7 @@ test_files:
1121
1155
  - spec/mongoid/persistable/updatable_spec.rb
1122
1156
  - spec/mongoid/persistable/upsertable_spec.rb
1123
1157
  - spec/mongoid/persistable_spec.rb
1158
+ - spec/mongoid/positional_spec.rb
1124
1159
  - spec/mongoid/query_cache_spec.rb
1125
1160
  - spec/mongoid/railties/document_spec.rb
1126
1161
  - spec/mongoid/relations/accessors_spec.rb
@@ -0,0 +1,3 @@
1
+ i��#�g��yP�̚
2
+ �lE0<|��'T���1�-��hA�-F��N~��%�R�E���h��ꓬ15xA�i}� �&�k��f+����
3
+ .U,ڽ�e��Z��씝Z�xjK]0Ry+� ����;��(�e�