mongoid 8.0.1 → 8.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/config/locales/en.yml +1 -0
  4. data/lib/mongoid/association/accessors.rb +6 -6
  5. data/lib/mongoid/association/bindable.rb +2 -2
  6. data/lib/mongoid/association/constrainable.rb +0 -1
  7. data/lib/mongoid/association/embedded/batchable.rb +5 -5
  8. data/lib/mongoid/association/embedded/cyclic.rb +1 -1
  9. data/lib/mongoid/association/embedded/embedded_in/proxy.rb +2 -2
  10. data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
  11. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +10 -10
  12. data/lib/mongoid/association/embedded/embeds_many.rb +2 -2
  13. data/lib/mongoid/association/embedded/embeds_one/proxy.rb +2 -2
  14. data/lib/mongoid/association/embedded/embeds_one.rb +3 -3
  15. data/lib/mongoid/association/many.rb +6 -7
  16. data/lib/mongoid/association/nested/many.rb +3 -3
  17. data/lib/mongoid/association/nested/nested_buildable.rb +4 -4
  18. data/lib/mongoid/association/nested/one.rb +5 -5
  19. data/lib/mongoid/association/one.rb +2 -2
  20. data/lib/mongoid/association/options.rb +9 -9
  21. data/lib/mongoid/association/proxy.rb +2 -3
  22. data/lib/mongoid/association/referenced/auto_save.rb +1 -1
  23. data/lib/mongoid/association/referenced/belongs_to/proxy.rb +5 -6
  24. data/lib/mongoid/association/referenced/belongs_to.rb +1 -1
  25. data/lib/mongoid/association/referenced/counter_cache.rb +2 -2
  26. data/lib/mongoid/association/referenced/eager.rb +2 -2
  27. data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +2 -2
  28. data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +2 -2
  29. data/lib/mongoid/association/referenced/has_many/enumerable.rb +10 -10
  30. data/lib/mongoid/association/referenced/has_many/proxy.rb +12 -9
  31. data/lib/mongoid/association/referenced/has_many.rb +3 -3
  32. data/lib/mongoid/association/referenced/has_one/nested_builder.rb +5 -5
  33. data/lib/mongoid/association/referenced/has_one/proxy.rb +1 -1
  34. data/lib/mongoid/association/referenced/has_one.rb +3 -3
  35. data/lib/mongoid/association/referenced/syncable.rb +2 -2
  36. data/lib/mongoid/association/reflections.rb +2 -2
  37. data/lib/mongoid/association/relatable.rb +6 -6
  38. data/lib/mongoid/association.rb +5 -5
  39. data/lib/mongoid/atomic/modifiers.rb +2 -2
  40. data/lib/mongoid/attributes/dynamic.rb +3 -3
  41. data/lib/mongoid/attributes/nested.rb +5 -5
  42. data/lib/mongoid/attributes/processing.rb +1 -1
  43. data/lib/mongoid/attributes/projector.rb +1 -1
  44. data/lib/mongoid/attributes/readonly.rb +2 -2
  45. data/lib/mongoid/attributes.rb +13 -13
  46. data/lib/mongoid/changeable.rb +5 -5
  47. data/lib/mongoid/clients/options.rb +1 -1
  48. data/lib/mongoid/clients/validators/storage.rb +3 -3
  49. data/lib/mongoid/config/validators/client.rb +6 -6
  50. data/lib/mongoid/config.rb +7 -7
  51. data/lib/mongoid/contextual/aggregable/memory.rb +1 -1
  52. data/lib/mongoid/contextual/aggregable/mongo.rb +4 -4
  53. data/lib/mongoid/contextual/aggregable/none.rb +1 -1
  54. data/lib/mongoid/contextual/atomic.rb +1 -1
  55. data/lib/mongoid/contextual/geo_near.rb +7 -7
  56. data/lib/mongoid/contextual/memory.rb +5 -5
  57. data/lib/mongoid/contextual/mongo.rb +14 -14
  58. data/lib/mongoid/contextual/none.rb +2 -2
  59. data/lib/mongoid/contextual/queryable.rb +1 -1
  60. data/lib/mongoid/contextual.rb +2 -2
  61. data/lib/mongoid/criteria/findable.rb +7 -4
  62. data/lib/mongoid/criteria/includable.rb +1 -1
  63. data/lib/mongoid/criteria/permission.rb +1 -1
  64. data/lib/mongoid/criteria/queryable/aggregable.rb +2 -2
  65. data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
  66. data/lib/mongoid/criteria/queryable/extensions/regexp.rb +2 -2
  67. data/lib/mongoid/criteria/queryable/extensions/set.rb +1 -1
  68. data/lib/mongoid/criteria/queryable/extensions/string.rb +3 -3
  69. data/lib/mongoid/criteria/queryable/extensions/symbol.rb +1 -1
  70. data/lib/mongoid/criteria/queryable/key.rb +3 -3
  71. data/lib/mongoid/criteria/queryable/optional.rb +2 -2
  72. data/lib/mongoid/criteria/queryable/options.rb +1 -1
  73. data/lib/mongoid/criteria/queryable/pipeline.rb +1 -1
  74. data/lib/mongoid/criteria/queryable/selectable.rb +3 -3
  75. data/lib/mongoid/criteria/queryable/selector.rb +3 -3
  76. data/lib/mongoid/criteria/queryable/smash.rb +1 -1
  77. data/lib/mongoid/criteria/queryable.rb +1 -1
  78. data/lib/mongoid/criteria/scopable.rb +2 -2
  79. data/lib/mongoid/criteria.rb +14 -9
  80. data/lib/mongoid/deprecable.rb +1 -1
  81. data/lib/mongoid/document.rb +2 -2
  82. data/lib/mongoid/equality.rb +12 -12
  83. data/lib/mongoid/errors/document_not_found.rb +5 -5
  84. data/lib/mongoid/errors/invalid_config_option.rb +1 -1
  85. data/lib/mongoid/errors/invalid_dependent_strategy.rb +1 -1
  86. data/lib/mongoid/errors/invalid_field.rb +1 -1
  87. data/lib/mongoid/errors/invalid_relation.rb +1 -1
  88. data/lib/mongoid/errors/invalid_relation_option.rb +1 -1
  89. data/lib/mongoid/errors/invalid_session_use.rb +1 -1
  90. data/lib/mongoid/errors/invalid_storage_options.rb +1 -1
  91. data/lib/mongoid/errors/mongoid_error.rb +3 -3
  92. data/lib/mongoid/errors/nested_attributes_metadata_not_found.rb +1 -1
  93. data/lib/mongoid/errors/no_client_database.rb +1 -1
  94. data/lib/mongoid/errors/no_client_hosts.rb +1 -1
  95. data/lib/mongoid/errors/readonly_attribute.rb +1 -1
  96. data/lib/mongoid/errors/unknown_attribute.rb +1 -1
  97. data/lib/mongoid/extensions/array.rb +1 -1
  98. data/lib/mongoid/extensions/false_class.rb +1 -1
  99. data/lib/mongoid/extensions/hash.rb +1 -1
  100. data/lib/mongoid/extensions/module.rb +1 -1
  101. data/lib/mongoid/extensions/object.rb +6 -6
  102. data/lib/mongoid/extensions/string.rb +9 -9
  103. data/lib/mongoid/extensions/symbol.rb +1 -1
  104. data/lib/mongoid/extensions/true_class.rb +1 -1
  105. data/lib/mongoid/fields/foreign_key.rb +4 -4
  106. data/lib/mongoid/fields/localized.rb +2 -2
  107. data/lib/mongoid/fields/standard.rb +7 -7
  108. data/lib/mongoid/fields.rb +9 -9
  109. data/lib/mongoid/findable.rb +7 -6
  110. data/lib/mongoid/indexable/specification.rb +1 -1
  111. data/lib/mongoid/indexable/validators/options.rb +2 -1
  112. data/lib/mongoid/interceptable.rb +4 -4
  113. data/lib/mongoid/matchable.rb +1 -1
  114. data/lib/mongoid/matcher.rb +12 -7
  115. data/lib/mongoid/persistable/creatable.rb +4 -4
  116. data/lib/mongoid/persistable/deletable.rb +1 -1
  117. data/lib/mongoid/persistable/destroyable.rb +1 -1
  118. data/lib/mongoid/persistable/savable.rb +2 -2
  119. data/lib/mongoid/persistable/unsettable.rb +1 -1
  120. data/lib/mongoid/persistable/updatable.rb +7 -7
  121. data/lib/mongoid/persistable/upsertable.rb +1 -1
  122. data/lib/mongoid/persistable.rb +3 -3
  123. data/lib/mongoid/persistence_context.rb +3 -3
  124. data/lib/mongoid/query_cache.rb +2 -2
  125. data/lib/mongoid/scopable.rb +17 -15
  126. data/lib/mongoid/serializable.rb +10 -6
  127. data/lib/mongoid/stateful.rb +10 -10
  128. data/lib/mongoid/tasks/database.rb +0 -2
  129. data/lib/mongoid/threaded/lifecycle.rb +5 -5
  130. data/lib/mongoid/threaded.rb +9 -9
  131. data/lib/mongoid/timestamps/updated.rb +1 -1
  132. data/lib/mongoid/traversable.rb +3 -3
  133. data/lib/mongoid/validatable/localizable.rb +1 -1
  134. data/lib/mongoid/validatable/macros.rb +0 -2
  135. data/lib/mongoid/validatable/presence.rb +2 -2
  136. data/lib/mongoid/validatable/uniqueness.rb +7 -7
  137. data/lib/mongoid/validatable.rb +6 -6
  138. data/lib/mongoid/version.rb +1 -1
  139. data/spec/mongoid/equality_spec.rb +12 -12
  140. data/spec/mongoid/indexable_spec.rb +23 -1
  141. data/spec/mongoid/scopable_spec.rb +34 -16
  142. data.tar.gz.sig +0 -0
  143. metadata +2 -2
  144. metadata.gz.sig +0 -0
@@ -223,8 +223,11 @@ describe Mongoid::Indexable do
223
223
  let(:klass) do
224
224
  Class.new do
225
225
  include Mongoid::Document
226
- field :a, as: :authentication_token
226
+
227
227
  store_in collection: :specs
228
+
229
+ field :a, as: :authentication_token
230
+ field :username
228
231
  end
229
232
  end
230
233
 
@@ -588,6 +591,25 @@ describe Mongoid::Indexable do
588
591
  end
589
592
  end
590
593
 
594
+ context "when using a wildcard index" do
595
+
596
+ before do
597
+ klass.index({ '$**': 1 }, wildcard_projection: { _id: 1, username: 0 })
598
+ end
599
+
600
+ let(:spec) do
601
+ klass.index_specification('$**': 1)
602
+ end
603
+
604
+ it "creates the index" do
605
+ expect(spec).to be_a(Mongoid::Indexable::Specification)
606
+ end
607
+
608
+ it "sets the index with correct options" do
609
+ expect(spec.options).to eq(wildcard_projection: { _id: 1, username: 0 })
610
+ end
611
+ end
612
+
591
613
  context "when providing an invalid option" do
592
614
 
593
615
  it "raises an error" do
@@ -481,27 +481,45 @@ describe Mongoid::Scopable do
481
481
 
482
482
  context "when a block is provided" do
483
483
 
484
- before do
485
- Band.scope(:active, ->{ Band.where(active: true) }) do
486
- def add_origin
487
- tap { |c| c.selector[:origin] = "Deutschland" }
488
- end
484
+ context "when with optional and keyword arguments" do
485
+ before do
486
+ Band.scope(:named_by, ->(name, deleted: false) {
487
+ Band.where(name: name, deleted: deleted)
488
+ })
489
489
  end
490
- end
491
490
 
492
- after do
493
- class << Band
494
- undef_method :active
491
+ let(:scope) do
492
+ Band.named_by("Emily", deleted: true)
495
493
  end
496
- Band._declared_scopes.clear
497
- end
498
494
 
499
- let(:scope) do
500
- Band.active.add_origin
495
+ it "sets the conditions from keyword arguments" do
496
+ scope.selector.should == {'name' => 'Emily', 'deleted' => true}
497
+ end
501
498
  end
502
499
 
503
- it "adds the extension to the scope" do
504
- expect(scope.selector).to eq({ "active" => true, "origin" => "Deutschland" })
500
+ context "when without arguments" do
501
+ before do
502
+ Band.scope(:active, ->{ Band.where(active: true) }) do
503
+ def add_origin
504
+ tap { |c| c.selector[:origin] = "Deutschland" }
505
+ end
506
+ end
507
+ end
508
+
509
+ after do
510
+ class << Band
511
+ undef_method :active
512
+ end
513
+ Band._declared_scopes.clear
514
+ end
515
+
516
+ let(:scope) do
517
+ Band.active.add_origin
518
+ end
519
+
520
+ it "adds the extension to the scope" do
521
+ expect(scope.selector).to eq({ "active" => true, "origin" => "Deutschland" })
522
+ end
505
523
  end
506
524
  end
507
525
 
@@ -1173,7 +1191,7 @@ describe Mongoid::Scopable do
1173
1191
  end
1174
1192
  end
1175
1193
 
1176
- context 'when nesting unsoped under with_scope' do
1194
+ context 'when nesting unscoped under with_scope' do
1177
1195
  let(:c1) { Band.where(active: true) }
1178
1196
 
1179
1197
  it 'restores previous scope' do
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.1
4
+ version: 8.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan
@@ -30,7 +30,7 @@ cert_chain:
30
30
  +WyKQ+QTIdtDiyf2LQmxWnxt/W1CmScjdLS7/yXGkkB/D9Uy+sJD747O/B9P238Q
31
31
  XnerrtyOu04RsWDvaZkCwSDVzoqfICh4CP1mlde73Ts=
32
32
  -----END CERTIFICATE-----
33
- date: 2022-07-20 00:00:00.000000000 Z
33
+ date: 2022-07-23 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: activemodel
metadata.gz.sig CHANGED
Binary file