mongoid 6.4.2 → 7.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/config/locales/en.yml +17 -0
- data/lib/mongoid/association/accessors.rb +339 -0
- data/lib/mongoid/{relations/binding.rb → association/bindable.rb} +32 -52
- data/lib/mongoid/association/builders.rb +92 -0
- data/lib/mongoid/{relations/constraint.rb → association/constrainable.rb} +11 -22
- data/lib/mongoid/association/depending.rb +137 -0
- data/lib/mongoid/{relations/eager.rb → association/eager_loadable.rb} +11 -11
- data/lib/mongoid/{relations → association}/embedded/batchable.rb +19 -19
- data/lib/mongoid/association/embedded/cyclic.rb +109 -0
- data/lib/mongoid/association/embedded/embedded_in/binding.rb +56 -0
- data/lib/mongoid/{relations/builders/embedded/in.rb → association/embedded/embedded_in/buildable.rb} +12 -6
- data/lib/mongoid/association/embedded/embedded_in/proxy.rb +121 -0
- data/lib/mongoid/association/embedded/embedded_in.rb +154 -0
- data/lib/mongoid/{relations/bindings/embedded/many.rb → association/embedded/embeds_many/binding.rb} +11 -9
- data/lib/mongoid/{relations/builders/embedded/many.rb → association/embedded/embeds_many/buildable.rb} +13 -7
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +552 -0
- data/lib/mongoid/association/embedded/embeds_many.rb +210 -0
- data/lib/mongoid/{relations/bindings/embedded/one.rb → association/embedded/embeds_one/binding.rb} +12 -10
- data/lib/mongoid/{relations/builders/embedded/one.rb → association/embedded/embeds_one/buildable.rb} +13 -7
- data/lib/mongoid/association/embedded/embeds_one/proxy.rb +130 -0
- data/lib/mongoid/association/embedded/embeds_one.rb +173 -0
- data/lib/mongoid/association/embedded.rb +4 -0
- data/lib/mongoid/association/macros.rb +204 -0
- data/lib/mongoid/{relations → association}/many.rb +19 -49
- data/lib/mongoid/{relations → association}/marshalable.rb +6 -4
- data/lib/mongoid/association/nested/many.rb +200 -0
- data/lib/mongoid/association/nested/nested_buildable.rb +72 -0
- data/lib/mongoid/association/nested/one.rb +127 -0
- data/lib/mongoid/association/nested.rb +15 -0
- data/lib/mongoid/{relations → association}/one.rb +6 -6
- data/lib/mongoid/association/options.rb +152 -0
- data/lib/mongoid/{relations → association}/proxy.rb +31 -58
- data/lib/mongoid/association/referenced/auto_save.rb +79 -0
- data/lib/mongoid/association/referenced/belongs_to/binding.rb +87 -0
- data/lib/mongoid/association/referenced/belongs_to/buildable.rb +46 -0
- data/lib/mongoid/association/referenced/belongs_to/eager.rb +36 -0
- data/lib/mongoid/association/referenced/belongs_to/proxy.rb +136 -0
- data/lib/mongoid/association/referenced/belongs_to.rb +248 -0
- data/lib/mongoid/association/referenced/counter_cache.rb +163 -0
- data/lib/mongoid/association/referenced/eager.rb +162 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb +71 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb +40 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/eager.rb +52 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +312 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +290 -0
- data/lib/mongoid/{relations/bindings/referenced/many.rb → association/referenced/has_many/binding.rb} +6 -5
- data/lib/mongoid/association/referenced/has_many/buildable.rb +38 -0
- data/lib/mongoid/association/referenced/has_many/eager.rb +43 -0
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +510 -0
- data/lib/mongoid/association/referenced/has_many/proxy.rb +578 -0
- data/lib/mongoid/association/referenced/has_many.rb +275 -0
- data/lib/mongoid/{relations/bindings/referenced/one.rb → association/referenced/has_one/binding.rb} +11 -8
- data/lib/mongoid/association/referenced/has_one/buildable.rb +60 -0
- data/lib/mongoid/association/referenced/has_one/eager.rb +35 -0
- data/lib/mongoid/{relations/builders/nested_attributes/one.rb → association/referenced/has_one/nested_builder.rb} +9 -9
- data/lib/mongoid/association/referenced/has_one/proxy.rb +113 -0
- data/lib/mongoid/association/referenced/has_one.rb +204 -0
- data/lib/mongoid/association/referenced/syncable.rb +170 -0
- data/lib/mongoid/association/referenced.rb +7 -0
- data/lib/mongoid/{relations → association}/reflections.rb +21 -17
- data/lib/mongoid/association/relatable.rb +509 -0
- data/lib/mongoid/{relations.rb → association.rb} +57 -56
- data/lib/mongoid/atomic/paths/embedded/many.rb +1 -1
- data/lib/mongoid/atomic/paths/embedded/one.rb +1 -1
- data/lib/mongoid/atomic.rb +4 -4
- data/lib/mongoid/attributes/dynamic.rb +2 -2
- data/lib/mongoid/attributes/nested.rb +22 -11
- data/lib/mongoid/attributes/processing.rb +2 -2
- data/lib/mongoid/attributes/readonly.rb +2 -4
- data/lib/mongoid/attributes.rb +22 -13
- data/lib/mongoid/changeable.rb +1 -1
- data/lib/mongoid/clients/options.rb +7 -5
- data/lib/mongoid/composable.rb +4 -4
- data/lib/mongoid/config.rb +1 -0
- data/lib/mongoid/contextual/atomic.rb +1 -1
- data/lib/mongoid/contextual/geo_near.rb +1 -1
- data/lib/mongoid/contextual/memory.rb +21 -3
- data/lib/mongoid/contextual/mongo.rb +10 -8
- data/lib/mongoid/copyable.rb +7 -6
- data/lib/mongoid/criteria/includable.rb +14 -14
- data/lib/mongoid/criteria/modifiable.rb +8 -14
- data/lib/mongoid/criteria/options.rb +2 -2
- data/lib/mongoid/criteria/queryable/extensions/string.rb +1 -1
- data/lib/mongoid/criteria/queryable/pipeline.rb +10 -5
- data/lib/mongoid/criteria/queryable/selectable.rb +37 -7
- data/lib/mongoid/criteria.rb +2 -2
- data/lib/mongoid/document.rb +15 -6
- data/lib/mongoid/errors/invalid_dependent_strategy.rb +32 -0
- data/lib/mongoid/errors/invalid_relation_option.rb +29 -0
- data/lib/mongoid/errors/unknown_model.rb +25 -0
- data/lib/mongoid/errors.rb +3 -0
- data/lib/mongoid/extensions/array.rb +5 -5
- data/lib/mongoid/extensions/big_decimal.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +5 -2
- data/lib/mongoid/extensions/object.rb +4 -4
- data/lib/mongoid/extensions/range.rb +1 -0
- data/lib/mongoid/extensions/regexp.rb +1 -0
- data/lib/mongoid/extensions.rb +0 -4
- data/lib/mongoid/factory.rb +13 -3
- data/lib/mongoid/fields/foreign_key.rb +5 -5
- data/lib/mongoid/fields/standard.rb +2 -14
- data/lib/mongoid/fields/validators/macro.rb +1 -1
- data/lib/mongoid/fields.rb +3 -3
- data/lib/mongoid/indexable.rb +4 -1
- data/lib/mongoid/interceptable.rb +5 -5
- data/lib/mongoid/matchable/and.rb +1 -1
- data/lib/mongoid/matchable/elem_match.rb +9 -3
- data/lib/mongoid/matchable/eq.rb +22 -0
- data/lib/mongoid/matchable/ne.rb +1 -1
- data/lib/mongoid/matchable.rb +3 -1
- data/lib/mongoid/persistable/deletable.rb +7 -6
- data/lib/mongoid/persistable/incrementable.rb +1 -1
- data/lib/mongoid/persistable/logical.rb +1 -1
- data/lib/mongoid/persistable/settable.rb +57 -12
- data/lib/mongoid/persistable.rb +4 -5
- data/lib/mongoid/persistence_context.rb +20 -5
- data/lib/mongoid/query_cache.rb +8 -4
- data/lib/mongoid/railtie.rb +17 -0
- data/lib/mongoid/railties/controller_runtime.rb +86 -0
- data/lib/mongoid/scopable.rb +3 -3
- data/lib/mongoid/serializable.rb +4 -4
- data/lib/mongoid/shardable.rb +1 -1
- data/lib/mongoid/threaded.rb +36 -0
- data/lib/mongoid/touchable.rb +102 -0
- data/lib/mongoid/traversable.rb +3 -3
- data/lib/mongoid/validatable/presence.rb +2 -2
- data/lib/mongoid/validatable/uniqueness.rb +4 -4
- data/lib/mongoid/validatable.rb +8 -8
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +3 -0
- data/spec/app/models/animal.rb +2 -1
- data/spec/app/models/bomb.rb +1 -1
- data/spec/app/models/message.rb +1 -1
- data/spec/app/models/minim.rb +7 -0
- data/spec/app/models/person.rb +5 -2
- data/spec/app/models/shipment_address.rb +1 -0
- data/spec/app/models/store_as_dup_test3.rb +7 -0
- data/spec/app/models/store_as_dup_test4.rb +7 -0
- data/spec/app/models/updatable.rb +7 -0
- data/spec/app/models/vertex.rb +6 -0
- data/spec/app/models/wiki_page.rb +1 -1
- data/spec/config/mongoid.yml +13 -3
- data/spec/integration/associations/belongs_to_spec.rb +13 -0
- data/spec/lite_spec_helper.rb +56 -0
- data/spec/mongoid/{relations → association}/accessors_spec.rb +40 -1
- data/spec/mongoid/{relations → association}/auto_save_spec.rb +60 -12
- data/spec/mongoid/{relations → association}/builders_spec.rb +1 -1
- data/spec/mongoid/association/constrainable_spec.rb +115 -0
- data/spec/mongoid/{relations → association}/counter_cache_spec.rb +1 -1
- data/spec/mongoid/association/depending_spec.rb +866 -0
- data/spec/mongoid/{relations → association}/eager_spec.rb +12 -12
- data/spec/mongoid/{relations → association/embedded}/cyclic_spec.rb +1 -1
- data/spec/mongoid/{relations/bindings/embedded/in_spec.rb → association/embedded/embedded_in/binding_spec.rb} +13 -13
- data/spec/mongoid/{relations/builders/embedded/in_spec.rb → association/embedded/embedded_in/buildable_spec.rb} +9 -9
- data/spec/mongoid/{relations/embedded/in_spec.rb → association/embedded/embedded_in/proxy_spec.rb} +5 -77
- data/spec/mongoid/association/embedded/embedded_in_spec.rb +843 -0
- data/spec/mongoid/{relations/bindings/embedded/many_spec.rb → association/embedded/embeds_many/binding_spec.rb} +3 -3
- data/spec/mongoid/{relations/builders/embedded/many_spec.rb → association/embedded/embeds_many/buildable_spec.rb} +17 -45
- data/spec/mongoid/{relations/embedded/many_spec.rb → association/embedded/embeds_many/proxy_spec.rb} +124 -182
- data/spec/mongoid/association/embedded/embeds_many_spec.rb +852 -0
- data/spec/mongoid/{relations/bindings/embedded/one_spec.rb → association/embedded/embeds_one/binding_spec.rb} +4 -4
- data/spec/mongoid/{relations/builders/embedded/one_spec.rb → association/embedded/embeds_one/buildable_spec.rb} +14 -34
- data/spec/mongoid/{relations/embedded/one_spec.rb → association/embedded/embeds_one/proxy_spec.rb} +39 -84
- data/spec/mongoid/association/embedded/embeds_one_spec.rb +908 -0
- data/spec/mongoid/{relations → association}/macros_spec.rb +148 -73
- data/spec/mongoid/{relations/builders/nested_attributes → association/nested}/many_spec.rb +16 -19
- data/spec/mongoid/{relations/builders/nested_attributes → association/nested}/one_spec.rb +17 -20
- data/spec/mongoid/association/options_spec.rb +1321 -0
- data/spec/mongoid/{relations → association}/polymorphic_spec.rb +66 -34
- data/spec/mongoid/{relations/bindings/referenced/in_spec.rb → association/referenced/belongs_to/binding_spec.rb} +7 -7
- data/spec/mongoid/{relations/builders/referenced/in_spec.rb → association/referenced/belongs_to/buildable_spec.rb} +46 -79
- data/spec/mongoid/{relations/eager/belongs_to_spec.rb → association/referenced/belongs_to/eager_spec.rb} +33 -14
- data/spec/mongoid/{relations/referenced/in_spec.rb → association/referenced/belongs_to/proxy_spec.rb} +57 -91
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +2006 -0
- data/spec/mongoid/{relations/bindings/referenced/many_to_many_spec.rb → association/referenced/has_and_belongs_to_many/binding_spec.rb} +5 -5
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb +121 -0
- data/spec/mongoid/{relations/eager/has_and_belongs_to_many_spec.rb → association/referenced/has_and_belongs_to_many/eager_spec.rb} +26 -7
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_persistence_spec.rb +56 -0
- data/spec/mongoid/{relations/referenced/many_to_many_spec.rb → association/referenced/has_and_belongs_to_many/proxy_spec.rb} +107 -98
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_models.rb +26 -0
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb +1027 -0
- data/spec/mongoid/{relations/bindings/referenced/many_spec.rb → association/referenced/has_many/binding_spec.rb} +5 -5
- data/spec/mongoid/association/referenced/has_many/buildable_spec.rb +119 -0
- data/spec/mongoid/{relations/eager/has_many_spec.rb → association/referenced/has_many/eager_spec.rb} +26 -11
- data/spec/mongoid/{relations/targets → association/referenced/has_many}/enumerable_spec.rb +122 -1
- data/spec/mongoid/association/referenced/has_many/proxy_query_spec.rb +23 -0
- data/spec/mongoid/{relations/referenced/many_spec.rb → association/referenced/has_many/proxy_spec.rb} +28 -93
- data/spec/mongoid/association/referenced/has_many_models.rb +37 -0
- data/spec/mongoid/association/referenced/has_many_spec.rb +1225 -0
- data/spec/mongoid/{relations/bindings/referenced/one_spec.rb → association/referenced/has_one/binding_spec.rb} +4 -4
- data/spec/mongoid/association/referenced/has_one/buildable_spec.rb +113 -0
- data/spec/mongoid/{relations/eager/has_one_spec.rb → association/referenced/has_one/eager_spec.rb} +10 -10
- data/spec/mongoid/{relations/referenced/one_spec.rb → association/referenced/has_one/proxy_spec.rb} +9 -109
- data/spec/mongoid/association/referenced/has_one_models.rb +48 -0
- data/spec/mongoid/association/referenced/has_one_spec.rb +1350 -0
- data/spec/mongoid/{relations → association}/reflections_spec.rb +1 -12
- data/spec/mongoid/{relations/synchronization_spec.rb → association/syncable_spec.rb} +4 -2
- data/spec/mongoid/{relations_spec.rb → association_spec.rb} +1 -1
- data/spec/mongoid/atomic/modifiers_spec.rb +2 -2
- data/spec/mongoid/atomic_spec.rb +4 -4
- data/spec/mongoid/attributes/nested_spec.rb +29 -11
- data/spec/mongoid/attributes/readonly_spec.rb +80 -125
- data/spec/mongoid/attributes_spec.rb +38 -2
- data/spec/mongoid/clients/factory_spec.rb +24 -18
- data/spec/mongoid/clients/options_spec.rb +58 -44
- data/spec/mongoid/clients/sessions_spec.rb +1 -1
- data/spec/mongoid/clients/transactions_spec.rb +369 -0
- data/spec/mongoid/clients_spec.rb +68 -8
- data/spec/mongoid/config_spec.rb +27 -1
- data/spec/mongoid/contextual/memory_spec.rb +19 -0
- data/spec/mongoid/contextual/mongo_spec.rb +33 -5
- data/spec/mongoid/copyable_spec.rb +90 -6
- data/spec/mongoid/copyable_spec_models.rb +17 -0
- data/spec/mongoid/criteria/modifiable_spec.rb +183 -60
- data/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb +3 -3
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +43 -0
- data/spec/mongoid/criteria/queryable/pipeline_spec.rb +12 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +42 -3
- data/spec/mongoid/criteria/queryable/selector_spec.rb +2 -2
- data/spec/mongoid/criteria/scopable_spec.rb +81 -0
- data/spec/mongoid/criteria_spec.rb +33 -18
- data/spec/mongoid/document_spec.rb +83 -4
- data/spec/mongoid/extensions/array_spec.rb +11 -15
- data/spec/mongoid/extensions/big_decimal_spec.rb +9 -9
- data/spec/mongoid/extensions/hash_spec.rb +18 -1
- data/spec/mongoid/extensions/object_spec.rb +7 -11
- data/spec/mongoid/extensions/range_spec.rb +7 -0
- data/spec/mongoid/extensions/regexp_spec.rb +23 -0
- data/spec/mongoid/factory_spec.rb +19 -1
- data/spec/mongoid/fields/foreign_key_spec.rb +24 -32
- data/spec/mongoid/fields_spec.rb +2 -2
- data/spec/mongoid/findable_spec.rb +1 -1
- data/spec/mongoid/indexable_spec.rb +18 -8
- data/spec/mongoid/interceptable_spec.rb +22 -1
- data/spec/mongoid/matchable/elem_match_spec.rb +20 -0
- data/spec/mongoid/matchable/eq_spec.rb +48 -0
- data/spec/mongoid/persistable/incrementable_spec.rb +6 -6
- data/spec/mongoid/persistable/savable_spec.rb +2 -2
- data/spec/mongoid/persistable/settable_spec.rb +95 -10
- data/spec/mongoid/persistable_spec.rb +21 -6
- data/spec/mongoid/persistence_context_spec.rb +1 -1
- data/spec/mongoid/query_cache_spec.rb +61 -22
- data/spec/mongoid/relations/proxy_spec.rb +124 -124
- data/spec/mongoid/scopable_spec.rb +13 -0
- data/spec/mongoid/shardable_spec.rb +32 -12
- data/spec/mongoid/threaded_spec.rb +68 -0
- data/spec/mongoid/{relations/touchable_spec.rb → touchable_spec.rb} +40 -1
- data/spec/mongoid/validatable/associated_spec.rb +1 -1
- data/spec/mongoid/validatable/presence_spec.rb +7 -6
- data/spec/mongoid/validatable_spec.rb +1 -1
- data/spec/rails/controller_extension/controller_runtime_spec.rb +110 -0
- data/spec/spec_helper.rb +51 -25
- data/spec/support/constraints.rb +101 -0
- data/spec/support/macros.rb +20 -0
- data/spec/support/spec_config.rb +39 -0
- metadata +602 -582
- checksums.yaml.gz.sig +0 -2
- data/lib/mongoid/relations/accessors.rb +0 -267
- data/lib/mongoid/relations/auto_save.rb +0 -94
- data/lib/mongoid/relations/bindings/embedded/in.rb +0 -59
- data/lib/mongoid/relations/bindings/referenced/in.rb +0 -65
- data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +0 -70
- data/lib/mongoid/relations/bindings.rb +0 -9
- data/lib/mongoid/relations/builder.rb +0 -57
- data/lib/mongoid/relations/builders/nested_attributes/many.rb +0 -199
- data/lib/mongoid/relations/builders/referenced/in.rb +0 -26
- data/lib/mongoid/relations/builders/referenced/many.rb +0 -26
- data/lib/mongoid/relations/builders/referenced/many_to_many.rb +0 -39
- data/lib/mongoid/relations/builders/referenced/one.rb +0 -26
- data/lib/mongoid/relations/builders.rb +0 -106
- data/lib/mongoid/relations/cascading/delete.rb +0 -44
- data/lib/mongoid/relations/cascading/destroy.rb +0 -43
- data/lib/mongoid/relations/cascading/nullify.rb +0 -35
- data/lib/mongoid/relations/cascading/restrict.rb +0 -39
- data/lib/mongoid/relations/cascading.rb +0 -56
- data/lib/mongoid/relations/conversions.rb +0 -34
- data/lib/mongoid/relations/counter_cache.rb +0 -160
- data/lib/mongoid/relations/cyclic.rb +0 -107
- data/lib/mongoid/relations/eager/base.rb +0 -153
- data/lib/mongoid/relations/eager/belongs_to.rb +0 -31
- data/lib/mongoid/relations/eager/has_and_belongs_to_many.rb +0 -47
- data/lib/mongoid/relations/eager/has_many.rb +0 -38
- data/lib/mongoid/relations/eager/has_one.rb +0 -30
- data/lib/mongoid/relations/embedded/in.rb +0 -241
- data/lib/mongoid/relations/embedded/many.rb +0 -683
- data/lib/mongoid/relations/embedded/one.rb +0 -235
- data/lib/mongoid/relations/macros.rb +0 -367
- data/lib/mongoid/relations/metadata.rb +0 -1179
- data/lib/mongoid/relations/nested_builder.rb +0 -74
- data/lib/mongoid/relations/options.rb +0 -49
- data/lib/mongoid/relations/polymorphic.rb +0 -39
- data/lib/mongoid/relations/referenced/in.rb +0 -304
- data/lib/mongoid/relations/referenced/many.rb +0 -812
- data/lib/mongoid/relations/referenced/many_to_many.rb +0 -479
- data/lib/mongoid/relations/referenced/one.rb +0 -290
- data/lib/mongoid/relations/synchronization.rb +0 -169
- data/lib/mongoid/relations/targets/enumerable.rb +0 -493
- data/lib/mongoid/relations/targets.rb +0 -2
- data/lib/mongoid/relations/touchable.rb +0 -97
- data/spec/mongoid/fields/internal/foreign_keys/array_spec.rb +0 -184
- data/spec/mongoid/fields/internal/foreign_keys/object_spec.rb +0 -201
- data/spec/mongoid/relations/builders/referenced/many_spec.rb +0 -137
- data/spec/mongoid/relations/builders/referenced/many_to_many_spec.rb +0 -178
- data/spec/mongoid/relations/builders/referenced/one_spec.rb +0 -111
- data/spec/mongoid/relations/cascading/delete_spec.rb +0 -101
- data/spec/mongoid/relations/cascading/destroy_spec.rb +0 -47
- data/spec/mongoid/relations/cascading/nullify_spec.rb +0 -32
- data/spec/mongoid/relations/cascading/restrict_spec.rb +0 -68
- data/spec/mongoid/relations/cascading_spec.rb +0 -355
- data/spec/mongoid/relations/constraint_spec.rb +0 -75
- data/spec/mongoid/relations/conversions_spec.rb +0 -128
- data/spec/mongoid/relations/metadata_spec.rb +0 -1985
- data/spec/mongoid/relations/options_spec.rb +0 -35
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
- /data/spec/mongoid/{relations → association}/embedded/dirty_spec.rb +0 -0
@@ -92,7 +92,7 @@ describe Mongoid::Factory do
|
|
92
92
|
context "when the type is a symbol" do
|
93
93
|
|
94
94
|
let(:person) do
|
95
|
-
described_class.build(Person, {:_type => "Doctor"})
|
95
|
+
described_class.build(Person, { :_type => "Doctor" })
|
96
96
|
end
|
97
97
|
|
98
98
|
it "instantiates the subclass" do
|
@@ -192,5 +192,23 @@ describe Mongoid::Factory do
|
|
192
192
|
expect(document.title).to eq("Sir")
|
193
193
|
end
|
194
194
|
end
|
195
|
+
|
196
|
+
context 'when type does not correspond to a Class name' do
|
197
|
+
|
198
|
+
let(:attributes) do
|
199
|
+
{ "title" => "Sir", "_type" => "invalid_class_name" }
|
200
|
+
end
|
201
|
+
|
202
|
+
let(:person) do
|
203
|
+
described_class.from_db(Person, attributes)
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'raises a exception' do
|
207
|
+
expect {
|
208
|
+
person
|
209
|
+
}.to raise_exception(Mongoid::Errors::UnknownModel)
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
195
213
|
end
|
196
214
|
end
|
@@ -7,7 +7,7 @@ describe Mongoid::Fields::ForeignKey do
|
|
7
7
|
let(:field) do
|
8
8
|
described_class.new(
|
9
9
|
:vals,
|
10
|
-
|
10
|
+
association: Person.relations["preferences"],
|
11
11
|
type: Array,
|
12
12
|
default: [],
|
13
13
|
identity: true
|
@@ -68,7 +68,7 @@ describe Mongoid::Fields::ForeignKey do
|
|
68
68
|
let(:field) do
|
69
69
|
described_class.new(
|
70
70
|
:vals,
|
71
|
-
|
71
|
+
association: Person.relations["posts"],
|
72
72
|
type: Array,
|
73
73
|
default: default,
|
74
74
|
identity: true
|
@@ -89,7 +89,7 @@ describe Mongoid::Fields::ForeignKey do
|
|
89
89
|
let(:field) do
|
90
90
|
described_class.new(
|
91
91
|
:vals,
|
92
|
-
|
92
|
+
association: Person.relations["posts"],
|
93
93
|
type: Array,
|
94
94
|
default: [],
|
95
95
|
identity: true
|
@@ -103,14 +103,14 @@ describe Mongoid::Fields::ForeignKey do
|
|
103
103
|
|
104
104
|
describe "#evolve" do
|
105
105
|
|
106
|
-
let(:
|
106
|
+
let(:association) do
|
107
107
|
Person.reflect_on_association(:preferences)
|
108
108
|
end
|
109
109
|
|
110
110
|
context "when provided a document" do
|
111
111
|
|
112
112
|
let(:field) do
|
113
|
-
described_class.new(:person_id, type: Object,
|
113
|
+
described_class.new(:person_id, type: Object, association: association)
|
114
114
|
end
|
115
115
|
|
116
116
|
let(:game) do
|
@@ -129,7 +129,7 @@ describe Mongoid::Fields::ForeignKey do
|
|
129
129
|
context "when the type is an array" do
|
130
130
|
|
131
131
|
let(:field) do
|
132
|
-
described_class.new(:preference_ids, type: Array, default: [],
|
132
|
+
described_class.new(:preference_ids, type: Array, default: [], association: association)
|
133
133
|
end
|
134
134
|
|
135
135
|
context "when providing a single value" do
|
@@ -197,12 +197,12 @@ describe Mongoid::Fields::ForeignKey do
|
|
197
197
|
|
198
198
|
context "when the relation stores ids as strings" do
|
199
199
|
|
200
|
-
let!(:
|
200
|
+
let!(:association) do
|
201
201
|
Agent.reflect_on_association(:accounts)
|
202
202
|
end
|
203
203
|
|
204
204
|
let!(:field) do
|
205
|
-
described_class.new(:account_ids, type: Array, default: [],
|
205
|
+
described_class.new(:account_ids, type: Array, default: [], association: association)
|
206
206
|
end
|
207
207
|
|
208
208
|
let(:id_one) do
|
@@ -260,12 +260,12 @@ describe Mongoid::Fields::ForeignKey do
|
|
260
260
|
|
261
261
|
context "when the type is an object" do
|
262
262
|
|
263
|
-
let(:
|
263
|
+
let(:association) do
|
264
264
|
Game.reflect_on_association(:person)
|
265
265
|
end
|
266
266
|
|
267
267
|
let(:field) do
|
268
|
-
described_class.new(:person_id, type: Object,
|
268
|
+
described_class.new(:person_id, type: Object, association: association)
|
269
269
|
end
|
270
270
|
|
271
271
|
context "when providing a single value" do
|
@@ -312,12 +312,12 @@ describe Mongoid::Fields::ForeignKey do
|
|
312
312
|
|
313
313
|
context "when the relation stores string ids" do
|
314
314
|
|
315
|
-
let(:
|
315
|
+
let(:association) do
|
316
316
|
Comment.reflect_on_association(:account)
|
317
317
|
end
|
318
318
|
|
319
319
|
let(:field) do
|
320
|
-
described_class.new(:person_id, type: Object,
|
320
|
+
described_class.new(:person_id, type: Object, association: association)
|
321
321
|
end
|
322
322
|
|
323
323
|
context "when the value is an id string" do
|
@@ -384,12 +384,12 @@ describe Mongoid::Fields::ForeignKey do
|
|
384
384
|
|
385
385
|
context "when the relation stores ids as strings" do
|
386
386
|
|
387
|
-
let(:
|
387
|
+
let(:association) do
|
388
388
|
Comment.reflect_on_association(:account)
|
389
389
|
end
|
390
390
|
|
391
391
|
let(:field) do
|
392
|
-
described_class.new(:person_id, type: Object,
|
392
|
+
described_class.new(:person_id, type: Object, association: association)
|
393
393
|
end
|
394
394
|
|
395
395
|
let(:id_one) do
|
@@ -445,14 +445,14 @@ describe Mongoid::Fields::ForeignKey do
|
|
445
445
|
end
|
446
446
|
end
|
447
447
|
|
448
|
-
context "when the
|
448
|
+
context "when the association is polymoprhic" do
|
449
449
|
|
450
|
-
let(:
|
450
|
+
let(:association) do
|
451
451
|
Agent.reflect_on_association(:names)
|
452
452
|
end
|
453
453
|
|
454
454
|
let(:field) do
|
455
|
-
described_class.new(:nameable_id, type: Object,
|
455
|
+
described_class.new(:nameable_id, type: Object, association: association)
|
456
456
|
end
|
457
457
|
|
458
458
|
let(:value) do
|
@@ -464,7 +464,7 @@ describe Mongoid::Fields::ForeignKey do
|
|
464
464
|
end
|
465
465
|
|
466
466
|
it "does not change the foreign key" do
|
467
|
-
expect(evolved).to
|
467
|
+
expect(evolved).to eq(BSON::ObjectId.from_string(value))
|
468
468
|
end
|
469
469
|
end
|
470
470
|
end
|
@@ -500,12 +500,8 @@ describe Mongoid::Fields::ForeignKey do
|
|
500
500
|
|
501
501
|
context "when the array is object ids" do
|
502
502
|
|
503
|
-
let(:
|
504
|
-
|
505
|
-
inverse_class_name: "Game",
|
506
|
-
name: :person,
|
507
|
-
relation: Mongoid::Relations::Referenced::In
|
508
|
-
)
|
503
|
+
let(:association) do
|
504
|
+
Game.relations["person"]
|
509
505
|
end
|
510
506
|
|
511
507
|
let(:field) do
|
@@ -514,7 +510,7 @@ describe Mongoid::Fields::ForeignKey do
|
|
514
510
|
type: Array,
|
515
511
|
default: [],
|
516
512
|
identity: true,
|
517
|
-
|
513
|
+
association: association,
|
518
514
|
overwrite: true
|
519
515
|
)
|
520
516
|
end
|
@@ -589,12 +585,8 @@ describe Mongoid::Fields::ForeignKey do
|
|
589
585
|
|
590
586
|
context "when the array is object ids" do
|
591
587
|
|
592
|
-
let(:
|
593
|
-
|
594
|
-
inverse_class_name: "Game",
|
595
|
-
name: :person,
|
596
|
-
relation: Mongoid::Relations::Referenced::In
|
597
|
-
)
|
588
|
+
let(:association) do
|
589
|
+
Game.relations['person']
|
598
590
|
end
|
599
591
|
|
600
592
|
let(:field) do
|
@@ -603,7 +595,7 @@ describe Mongoid::Fields::ForeignKey do
|
|
603
595
|
type: Object,
|
604
596
|
default: nil,
|
605
597
|
identity: true,
|
606
|
-
|
598
|
+
association: association,
|
607
599
|
overwrite: true
|
608
600
|
)
|
609
601
|
end
|
data/spec/mongoid/fields_spec.rb
CHANGED
@@ -816,7 +816,7 @@ describe Mongoid::Fields do
|
|
816
816
|
|
817
817
|
context "when the field name conflicts with mongoid's internals" do
|
818
818
|
|
819
|
-
[:
|
819
|
+
[:_association, :invalid].each do |meth|
|
820
820
|
context "when the field is named #{meth}" do
|
821
821
|
|
822
822
|
it "raises an error" do
|
@@ -1171,7 +1171,7 @@ describe Mongoid::Fields do
|
|
1171
1171
|
end
|
1172
1172
|
|
1173
1173
|
let(:decimal) do
|
1174
|
-
BigDecimal
|
1174
|
+
BigDecimal("1000000.00")
|
1175
1175
|
end
|
1176
1176
|
|
1177
1177
|
context "when setting to a big decimal" do
|
@@ -89,8 +89,9 @@ describe Mongoid::Indexable do
|
|
89
89
|
klass.create_indexes
|
90
90
|
end
|
91
91
|
|
92
|
-
it "creates the indexes" do
|
93
|
-
|
92
|
+
it "creates the indexes by using specified background option" do
|
93
|
+
index = klass.collection.indexes.get(_type: 1)
|
94
|
+
expect(index[:background]).to eq(true)
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
@@ -104,12 +105,9 @@ describe Mongoid::Indexable do
|
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
107
|
-
before do
|
108
|
-
klass.create_indexes
|
109
|
-
end
|
110
|
-
|
111
108
|
after do
|
112
109
|
klass.remove_indexes
|
110
|
+
Mongoid::Config.background_indexing = false
|
113
111
|
end
|
114
112
|
|
115
113
|
let(:indexes) do
|
@@ -118,8 +116,20 @@ describe Mongoid::Indexable do
|
|
118
116
|
end
|
119
117
|
end
|
120
118
|
|
121
|
-
it "creates the indexes" do
|
122
|
-
|
119
|
+
it "creates the indexes by using default background_indexing option" do
|
120
|
+
klass.create_indexes
|
121
|
+
|
122
|
+
index = indexes.get(_type: 1)
|
123
|
+
expect(index[:background]).to eq(Mongoid::Config.background_indexing)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "creates the indexes by using specified background_indexing option" do
|
127
|
+
Mongoid::Config.background_indexing = true
|
128
|
+
|
129
|
+
klass.create_indexes
|
130
|
+
|
131
|
+
index = indexes.get(_type: 1)
|
132
|
+
expect(index[:background]).to eq(true)
|
123
133
|
end
|
124
134
|
end
|
125
135
|
|
@@ -526,6 +526,8 @@ describe Mongoid::Interceptable do
|
|
526
526
|
end
|
527
527
|
|
528
528
|
after(:all) do
|
529
|
+
# ActiveSupport may raise an error when trying to reset callbacks on all of Band's
|
530
|
+
# descendants, regardless of whether they have a particular callback defined.
|
529
531
|
begin; Band.reset_callbacks(:rearrange); rescue; end
|
530
532
|
end
|
531
533
|
|
@@ -597,7 +599,7 @@ describe Mongoid::Interceptable do
|
|
597
599
|
it "raises an error" do
|
598
600
|
expect {
|
599
601
|
Band.has_and_belongs_to_many :tags, cascade_callbacks: true
|
600
|
-
}.to raise_error(Mongoid::Errors::
|
602
|
+
}.to raise_error(Mongoid::Errors::InvalidRelationOption)
|
601
603
|
end
|
602
604
|
end
|
603
605
|
|
@@ -1181,6 +1183,25 @@ describe Mongoid::Interceptable do
|
|
1181
1183
|
end
|
1182
1184
|
end
|
1183
1185
|
|
1186
|
+
context 'when the parent is updated' do
|
1187
|
+
|
1188
|
+
let(:band) do
|
1189
|
+
Band.create(name: "Moderat")
|
1190
|
+
end
|
1191
|
+
|
1192
|
+
before do
|
1193
|
+
band.update(records: [ { name: 'Black on Both Sides' }])
|
1194
|
+
end
|
1195
|
+
|
1196
|
+
it 'executes the callback' do
|
1197
|
+
expect(band.records.first.before_validation_called).to be true
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
it 'persists the change' do
|
1201
|
+
expect(band.reload.records.first.before_validation_called).to be true
|
1202
|
+
end
|
1203
|
+
end
|
1204
|
+
|
1184
1205
|
context "when the child is persisted" do
|
1185
1206
|
|
1186
1207
|
let(:band) do
|
@@ -53,6 +53,19 @@ describe Mongoid::Matchable::ElemMatch do
|
|
53
53
|
expect(matcher._matches?("$elemMatch" => {"a" => {"$in" => [1]}, "b" => {"$gt" => 1}})).to be true
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
context "when using a $not operator that matches" do
|
58
|
+
|
59
|
+
it "returns true" do
|
60
|
+
expect(matcher._matches?("$elemMatch" => {"a" => {"$not" => 4}})).to be true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when using symbols and a :$not operator that matches" do
|
66
|
+
it "returns true" do
|
67
|
+
expect(matcher._matches?(:$elemMatch => {"a" => {:$not => 4}})).to be true
|
68
|
+
end
|
56
69
|
end
|
57
70
|
|
58
71
|
context "when there is not a sub document that matches the criteria" do
|
@@ -74,6 +87,13 @@ describe Mongoid::Matchable::ElemMatch do
|
|
74
87
|
expect(matcher._matches?("$elemMatch" => {"a" => {"$in" => [1]}, "b" => {"$gt" => 10}})).to be false
|
75
88
|
end
|
76
89
|
end
|
90
|
+
|
91
|
+
context "when using a $not operator that does not match" do
|
92
|
+
|
93
|
+
it "returns true" do
|
94
|
+
expect(matcher._matches?("$elemMatch" => {"a" => {"$not" => 1}})).to be true
|
95
|
+
end
|
96
|
+
end
|
77
97
|
end
|
78
98
|
|
79
99
|
context "when using a criteria that matches partially but not a single sub document" do
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Mongoid::Matchable::Eq do
|
6
|
+
|
7
|
+
let(:matcher) do
|
8
|
+
described_class.new("first")
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#_matches?" do
|
12
|
+
|
13
|
+
context "when the values are equal" do
|
14
|
+
|
15
|
+
it "returns true" do
|
16
|
+
expect(matcher._matches?("$eq" => "first")).to be true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "when the values are not equal" do
|
21
|
+
|
22
|
+
it "returns false" do
|
23
|
+
expect(matcher._matches?("$eq" => "second")).to be false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when the value is an array" do
|
28
|
+
|
29
|
+
let(:array_matcher) do
|
30
|
+
described_class.new([ "first" ])
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when the value is in the array" do
|
34
|
+
|
35
|
+
it "returns true" do
|
36
|
+
expect(array_matcher._matches?("$eq" => "first")).to be true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when the value is not in the array" do
|
41
|
+
|
42
|
+
it "returns false" do
|
43
|
+
expect(array_matcher._matches?("$eq" => "second")).to be false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -66,15 +66,15 @@ describe Mongoid::Persistable::Incrementable do
|
|
66
66
|
context "when providing big decimal values" do
|
67
67
|
|
68
68
|
let(:five) do
|
69
|
-
BigDecimal
|
69
|
+
BigDecimal("5.0")
|
70
70
|
end
|
71
71
|
|
72
72
|
let(:neg_ten) do
|
73
|
-
BigDecimal
|
73
|
+
BigDecimal("-10.0")
|
74
74
|
end
|
75
75
|
|
76
76
|
let(:thirty) do
|
77
|
-
BigDecimal
|
77
|
+
BigDecimal("30.0")
|
78
78
|
end
|
79
79
|
|
80
80
|
let!(:inc) do
|
@@ -151,15 +151,15 @@ describe Mongoid::Persistable::Incrementable do
|
|
151
151
|
context "when providing big decimal values" do
|
152
152
|
|
153
153
|
let(:five) do
|
154
|
-
BigDecimal
|
154
|
+
BigDecimal("5.0")
|
155
155
|
end
|
156
156
|
|
157
157
|
let(:neg_ten) do
|
158
|
-
BigDecimal
|
158
|
+
BigDecimal("-10.0")
|
159
159
|
end
|
160
160
|
|
161
161
|
let(:thirty) do
|
162
|
-
BigDecimal
|
162
|
+
BigDecimal("30.0")
|
163
163
|
end
|
164
164
|
|
165
165
|
let!(:inc) do
|
@@ -190,7 +190,7 @@ describe Mongoid::Persistable::Savable do
|
|
190
190
|
"name.first_name" => "Ryan"
|
191
191
|
},
|
192
192
|
"$push"=> {
|
193
|
-
"addresses" =>
|
193
|
+
"addresses" => { '$each' => [ { "_id" => address.id, "street" => "Bond St" } ] }
|
194
194
|
}
|
195
195
|
})
|
196
196
|
end
|
@@ -309,7 +309,7 @@ describe Mongoid::Persistable::Savable do
|
|
309
309
|
expect {
|
310
310
|
person.username = 'unloaded-attribute'
|
311
311
|
person.save
|
312
|
-
}.to raise_error(
|
312
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
313
313
|
end
|
314
314
|
|
315
315
|
context 'when the changed attribute is aliased' do
|
@@ -211,7 +211,7 @@ describe Mongoid::Persistable::Settable do
|
|
211
211
|
Church.new.tap do |a|
|
212
212
|
a.location = { 'city' => 'Berlin' }
|
213
213
|
a.name = 'Church1'
|
214
|
-
a.save
|
214
|
+
a.save!
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
@@ -280,7 +280,7 @@ describe Mongoid::Persistable::Settable do
|
|
280
280
|
|
281
281
|
context 'when the field is a nested hash' do
|
282
282
|
|
283
|
-
context 'when the field is
|
283
|
+
context 'when the field is set to an empty hash' do
|
284
284
|
|
285
285
|
before do
|
286
286
|
church.set('location' => {})
|
@@ -301,7 +301,7 @@ describe Mongoid::Persistable::Settable do
|
|
301
301
|
Church.new.tap do |a|
|
302
302
|
a.location = {'address' => {'city' => 'Berlin', 'street' => 'Yorckstr'}}
|
303
303
|
a.name = 'Church1'
|
304
|
-
a.save
|
304
|
+
a.save!
|
305
305
|
end
|
306
306
|
end
|
307
307
|
|
@@ -321,7 +321,7 @@ describe Mongoid::Persistable::Settable do
|
|
321
321
|
Church.new.tap do |a|
|
322
322
|
a.location = {'address' => {'city' => 'Berlin', 'street' => 'Yorckstr'}}
|
323
323
|
a.name = 'Church1'
|
324
|
-
a.save
|
324
|
+
a.save!
|
325
325
|
end
|
326
326
|
end
|
327
327
|
|
@@ -341,20 +341,105 @@ describe Mongoid::Persistable::Settable do
|
|
341
341
|
Church.new.tap do |a|
|
342
342
|
a.location = {'address' => {'state' => {'address' => {'city' => 'Berlin', 'street' => 'Yorckstr'}}}}
|
343
343
|
a.name = 'Church1'
|
344
|
-
a.save
|
344
|
+
a.save!
|
345
345
|
end
|
346
346
|
end
|
347
347
|
|
348
|
-
|
349
|
-
|
348
|
+
context 'setting value to a string' do
|
349
|
+
it 'keeps peer attributes of the nested hash' do
|
350
|
+
church.set('location.address.state.address.city' => 'Munich')
|
351
|
+
|
352
|
+
expect(church.name).to eq('Church1')
|
353
|
+
expect(church.location).to eql({'address' => {'state' => {'address' => {'city' => 'Munich', 'street' => 'Yorckstr'}}}})
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'removes lower level attributes of the nested hash' do
|
357
|
+
church.set('location.address.state.address' => 'hello')
|
358
|
+
|
359
|
+
expect(church.name).to eq('Church1')
|
360
|
+
expect(church.location).to eql({'address' => {'state' => {'address' => 'hello'}}})
|
361
|
+
end
|
350
362
|
end
|
351
363
|
|
352
|
-
|
353
|
-
|
354
|
-
|
364
|
+
context 'setting value to a hash' do
|
365
|
+
it 'keeps peer attributes of the nested hash' do
|
366
|
+
church.set('location.address.state.address.city' => {'hello' => 'world'})
|
367
|
+
|
368
|
+
expect(church.name).to eq('Church1')
|
369
|
+
expect(church.location).to eql({'address' => {'state' => {'address' => {'city' => {'hello' => 'world'}, 'street' => 'Yorckstr'}}}})
|
370
|
+
end
|
371
|
+
|
372
|
+
it 'removes lower level attributes of the nested hash' do
|
373
|
+
church.set('location.address.state.address' => {'hello' => 'world'})
|
374
|
+
|
375
|
+
expect(church.name).to eq('Church1')
|
376
|
+
expect(church.location).to eql({'address' => {'state' => {'address' => {'hello' => 'world'}}}})
|
377
|
+
end
|
355
378
|
end
|
356
379
|
end
|
357
380
|
end
|
381
|
+
|
382
|
+
context 'when nested field is an array' do
|
383
|
+
let(:church) do
|
384
|
+
Church.create!(
|
385
|
+
location: {'address' => ['one', 'two']}
|
386
|
+
)
|
387
|
+
end
|
388
|
+
|
389
|
+
context 'setting to a different array' do
|
390
|
+
it 'sets values to new array discarding old values' do
|
391
|
+
church.set('location.address' => ['three'])
|
392
|
+
|
393
|
+
expect(church.location).to eq('address' => ['three'])
|
394
|
+
church.reload
|
395
|
+
expect(church.location).to eq('address' => ['three'])
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
context 'changing from an array to a number' do
|
400
|
+
it 'sets value to the number' do
|
401
|
+
church.set('location.address' => 5)
|
402
|
+
|
403
|
+
expect(church.location).to eq('address' => 5)
|
404
|
+
church.reload
|
405
|
+
expect(church.location).to eq('address' => 5)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
context 'when nested field is not an array' do
|
411
|
+
let(:church) do
|
412
|
+
Church.create!(
|
413
|
+
location: {'address' => 5}
|
414
|
+
)
|
415
|
+
end
|
416
|
+
|
417
|
+
context 'setting to an array' do
|
418
|
+
it 'sets values to the array' do
|
419
|
+
church.set('location.address' => ['three'])
|
420
|
+
|
421
|
+
expect(church.location).to eq('address' => ['three'])
|
422
|
+
church.reload
|
423
|
+
expect(church.location).to eq('address' => ['three'])
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
context 'when nesting into a field that is not a hash' do
|
429
|
+
let(:church) do
|
430
|
+
Church.create!(
|
431
|
+
location: {'address' => 5}
|
432
|
+
)
|
433
|
+
end
|
434
|
+
|
435
|
+
it 'sets field to new hash value discarding original value' do
|
436
|
+
church.set('location.address.a' => 'test')
|
437
|
+
|
438
|
+
expect(church.location).to eq('address' => {'a' => 'test'})
|
439
|
+
church.reload
|
440
|
+
expect(church.location).to eq('address' => {'a' => 'test'})
|
441
|
+
end
|
442
|
+
end
|
358
443
|
end
|
359
444
|
|
360
445
|
context 'when the field is not already set locally' do
|