mongoid 6.4.8 → 7.0.0.beta
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.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Rakefile +0 -26
- data/lib/config/locales/en.yml +17 -21
- data/lib/mongoid.rb +2 -2
- data/lib/mongoid/association.rb +150 -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 +116 -0
- data/lib/mongoid/{relations/eager.rb → association/eager_loadable.rb} +11 -11
- data/lib/mongoid/association/embedded.rb +4 -0
- data/lib/mongoid/{relations → association}/embedded/batchable.rb +27 -53
- data/lib/mongoid/association/embedded/cyclic.rb +109 -0
- data/lib/mongoid/association/embedded/embedded_in.rb +154 -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/embeds_many.rb +210 -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 +529 -0
- data/lib/mongoid/association/embedded/embeds_one.rb +173 -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/macros.rb +204 -0
- data/lib/mongoid/{relations → association}/many.rb +18 -52
- data/lib/mongoid/{relations → association}/marshalable.rb +6 -4
- data/lib/mongoid/association/nested.rb +15 -0
- 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/{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.rb +7 -0
- data/lib/mongoid/association/referenced/auto_save.rb +79 -0
- data/lib/mongoid/association/referenced/belongs_to.rb +248 -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/counter_cache.rb +163 -0
- data/lib/mongoid/association/referenced/eager.rb +159 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +290 -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 +310 -0
- data/lib/mongoid/association/referenced/has_many.rb +273 -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 +479 -0
- data/lib/mongoid/association/referenced/has_many/proxy.rb +577 -0
- data/lib/mongoid/association/referenced/has_one.rb +204 -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/syncable.rb +170 -0
- data/lib/mongoid/{relations → association}/reflections.rb +21 -17
- data/lib/mongoid/association/relatable.rb +415 -0
- data/lib/mongoid/association/touchable.rb +97 -0
- data/lib/mongoid/atomic.rb +6 -6
- data/lib/mongoid/atomic/modifiers.rb +8 -12
- data/lib/mongoid/atomic/paths/embedded/many.rb +1 -1
- data/lib/mongoid/atomic/paths/embedded/one.rb +1 -1
- data/lib/mongoid/attributes.rb +2 -1
- data/lib/mongoid/attributes/nested.rb +10 -10
- data/lib/mongoid/attributes/processing.rb +2 -2
- data/lib/mongoid/attributes/readonly.rb +2 -4
- data/lib/mongoid/clients.rb +0 -2
- data/lib/mongoid/clients/options.rb +1 -1
- data/lib/mongoid/clients/storage_options.rb +0 -1
- data/lib/mongoid/composable.rb +3 -4
- data/lib/mongoid/config.rb +1 -0
- data/lib/mongoid/contextual/aggregable/mongo.rb +1 -1
- data/lib/mongoid/contextual/atomic.rb +3 -6
- data/lib/mongoid/contextual/map_reduce.rb +3 -7
- data/lib/mongoid/contextual/memory.rb +5 -10
- data/lib/mongoid/contextual/mongo.rb +10 -27
- data/lib/mongoid/copyable.rb +6 -6
- data/lib/mongoid/criteria.rb +1 -2
- data/lib/mongoid/criteria/includable.rb +14 -14
- data/lib/mongoid/criteria/modifiable.rb +8 -14
- data/lib/mongoid/criteria/queryable/mergeable.rb +1 -3
- data/lib/mongoid/criteria/queryable/pipeline.rb +10 -5
- data/lib/mongoid/criteria/queryable/selectable.rb +10 -34
- data/lib/mongoid/document.rb +6 -6
- data/lib/mongoid/errors.rb +3 -1
- 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/extensions/array.rb +5 -5
- data/lib/mongoid/extensions/big_decimal.rb +1 -1
- data/lib/mongoid/extensions/object.rb +4 -4
- data/lib/mongoid/extensions/range.rb +1 -0
- data/lib/mongoid/extensions/regexp.rb +0 -1
- data/lib/mongoid/extensions/string.rb +1 -3
- data/lib/mongoid/factory.rb +4 -3
- data/lib/mongoid/fields.rb +1 -1
- 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/indexable.rb +8 -5
- data/lib/mongoid/interceptable.rb +5 -5
- data/lib/mongoid/matchable.rb +0 -3
- data/lib/mongoid/persistable.rb +4 -5
- data/lib/mongoid/persistable/creatable.rb +2 -4
- data/lib/mongoid/persistable/deletable.rb +9 -10
- data/lib/mongoid/persistable/destroyable.rb +5 -1
- data/lib/mongoid/persistable/incrementable.rb +1 -1
- data/lib/mongoid/persistable/logical.rb +1 -1
- data/lib/mongoid/persistable/settable.rb +5 -5
- data/lib/mongoid/persistable/updatable.rb +2 -2
- data/lib/mongoid/persistable/upsertable.rb +1 -2
- data/lib/mongoid/persistence_context.rb +4 -9
- data/lib/mongoid/query_cache.rb +18 -65
- data/lib/mongoid/railtie.rb +0 -17
- data/lib/mongoid/reloadable.rb +1 -1
- data/lib/mongoid/scopable.rb +3 -3
- data/lib/mongoid/serializable.rb +3 -3
- data/lib/mongoid/tasks/database.rb +2 -3
- data/lib/mongoid/threaded.rb +0 -74
- data/lib/mongoid/traversable.rb +2 -2
- data/lib/mongoid/validatable.rb +8 -8
- data/lib/mongoid/validatable/presence.rb +2 -2
- data/lib/mongoid/validatable/uniqueness.rb +4 -4
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +3 -4
- data/spec/app/models/animal.rb +2 -1
- data/spec/app/models/band.rb +0 -1
- data/spec/app/models/bomb.rb +1 -1
- data/spec/app/models/message.rb +1 -1
- data/spec/app/models/person.rb +5 -2
- data/spec/app/models/vertex.rb +6 -0
- data/spec/app/models/wiki_page.rb +1 -1
- data/spec/config/mongoid.yml +1 -0
- data/spec/mongoid/{relations → association}/accessors_spec.rb +1 -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 +613 -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 → association}/embedded/dirty_spec.rb +0 -0
- 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} +140 -428
- 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 -93
- 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 +7 -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} +9 -9
- 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 +1963 -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} +5 -5
- 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_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} +11 -11
- data/spec/mongoid/{relations/targets → association/referenced/has_many}/enumerable_spec.rb +1 -109
- data/spec/mongoid/{relations/referenced/many_spec.rb → association/referenced/has_many/proxy_spec.rb} +28 -93
- 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_spec.rb +1244 -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 → association}/touchable_spec.rb +19 -1
- data/spec/mongoid/{relations_spec.rb → association_spec.rb} +1 -1
- data/spec/mongoid/atomic/modifiers_spec.rb +17 -17
- data/spec/mongoid/atomic_spec.rb +17 -17
- data/spec/mongoid/attributes/nested_spec.rb +14 -12
- data/spec/mongoid/attributes/readonly_spec.rb +80 -125
- data/spec/mongoid/clients/factory_spec.rb +28 -52
- data/spec/mongoid/clients/options_spec.rb +65 -69
- data/spec/mongoid/config_spec.rb +24 -0
- data/spec/mongoid/contextual/geo_near_spec.rb +0 -1
- data/spec/mongoid/contextual/mongo_spec.rb +4 -112
- 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/pipeline_spec.rb +12 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +6 -74
- data/spec/mongoid/criteria/queryable/selector_spec.rb +2 -2
- data/spec/mongoid/criteria/scopable_spec.rb +0 -81
- data/spec/mongoid/criteria_spec.rb +16 -19
- data/spec/mongoid/document_spec.rb +2 -56
- data/spec/mongoid/extensions/array_spec.rb +11 -15
- data/spec/mongoid/extensions/big_decimal_spec.rb +9 -9
- 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 +0 -23
- data/spec/mongoid/extensions/string_spec.rb +7 -35
- data/spec/mongoid/factory_spec.rb +18 -11
- 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 +21 -2
- data/spec/mongoid/matchable_spec.rb +1 -26
- data/spec/mongoid/persistable/deletable_spec.rb +0 -19
- data/spec/mongoid/persistable/destroyable_spec.rb +0 -19
- data/spec/mongoid/persistable/incrementable_spec.rb +6 -6
- data/spec/mongoid/persistable/savable_spec.rb +3 -3
- data/spec/mongoid/persistable/settable_spec.rb +1 -35
- data/spec/mongoid/persistable/updatable_spec.rb +2 -2
- data/spec/mongoid/persistable_spec.rb +16 -16
- data/spec/mongoid/persistence_context_spec.rb +0 -14
- data/spec/mongoid/positional_spec.rb +10 -10
- data/spec/mongoid/query_cache_spec.rb +18 -87
- data/spec/mongoid/relations/proxy_spec.rb +124 -124
- data/spec/mongoid/scopable_spec.rb +0 -13
- data/spec/mongoid/threaded_spec.rb +0 -68
- 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/spec_helper.rb +7 -83
- metadata +586 -611
- metadata.gz.sig +2 -5
- data/lib/mongoid/clients/sessions.rb +0 -113
- data/lib/mongoid/errors/invalid_session_use.rb +0 -24
- data/lib/mongoid/matchable/nor.rb +0 -37
- data/lib/mongoid/railties/controller_runtime.rb +0 -86
- data/lib/mongoid/relations.rb +0 -148
- data/lib/mongoid/relations/accessors.rb +0 -267
- data/lib/mongoid/relations/auto_save.rb +0 -94
- data/lib/mongoid/relations/bindings.rb +0 -9
- 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/builder.rb +0 -57
- data/lib/mongoid/relations/builders.rb +0 -106
- 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/cascading.rb +0 -56
- 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/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.rb +0 -2
- data/lib/mongoid/relations/targets/enumerable.rb +0 -493
- data/lib/mongoid/relations/touchable.rb +0 -97
- data/spec/app/models/array_field.rb +0 -7
- data/spec/app/models/delegating_patient.rb +0 -16
- data/spec/integration/document_spec.rb +0 -22
- data/spec/mongoid/clients/sessions_spec.rb +0 -334
- 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/matchable/nor_spec.rb +0 -209
- 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/spec/rails/controller_extension/controller_runtime_spec.rb +0 -110
- data/spec/support/cluster_config.rb +0 -158
- data/spec/support/constraints.rb +0 -101
- data/spec/support/macros.rb +0 -20
- data/spec/support/session_registry.rb +0 -50
- data/spec/support/spec_config.rb +0 -42
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
describe Mongoid::
|
|
3
|
+
describe Mongoid::Association::EagerLoadable do
|
|
4
4
|
|
|
5
5
|
describe ".preload" do
|
|
6
6
|
|
|
@@ -122,12 +122,12 @@ describe Mongoid::Relations::Eager do
|
|
|
122
122
|
Person.all.to_a
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
-
let(:
|
|
125
|
+
let(:posts_association) do
|
|
126
126
|
Person.reflect_on_association(:posts)
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
it "runs the has_many preload" do
|
|
130
|
-
expect(Mongoid::
|
|
130
|
+
expect(Mongoid::Association::Referenced::HasMany::Eager).to receive(:new).with([posts_association], docs).once.and_call_original
|
|
131
131
|
|
|
132
132
|
context.eager_load(docs)
|
|
133
133
|
end
|
|
@@ -154,31 +154,31 @@ describe Mongoid::Relations::Eager do
|
|
|
154
154
|
Person.all.to_a
|
|
155
155
|
end
|
|
156
156
|
|
|
157
|
-
let(:
|
|
157
|
+
let(:posts_association) do
|
|
158
158
|
Person.reflect_on_association(:posts)
|
|
159
159
|
end
|
|
160
160
|
|
|
161
|
-
let(:
|
|
161
|
+
let(:houses_association) do
|
|
162
162
|
Person.reflect_on_association(:houses)
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
-
let(:
|
|
165
|
+
let(:cat_association) do
|
|
166
166
|
Person.reflect_on_association(:cat)
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
it "runs the has_many preload" do
|
|
170
|
-
expect(Mongoid::
|
|
170
|
+
expect(Mongoid::Association::Referenced::HasMany::Eager).to receive(:new).with([posts_association], docs).once.and_call_original
|
|
171
171
|
|
|
172
172
|
context.eager_load(docs)
|
|
173
173
|
end
|
|
174
174
|
|
|
175
175
|
it "runs the has_one preload" do
|
|
176
|
-
expect(Mongoid::
|
|
176
|
+
expect(Mongoid::Association::Referenced::HasOne::Eager).to receive(:new).with([cat_association], docs).once.and_call_original
|
|
177
177
|
context.eager_load(docs)
|
|
178
178
|
end
|
|
179
179
|
|
|
180
180
|
it "runs the has_and_belongs_to_many preload" do
|
|
181
|
-
expect(Mongoid::
|
|
181
|
+
expect(Mongoid::Association::Referenced::HasAndBelongsToMany::Eager).to receive(:new).with([houses_association], docs).once.and_call_original
|
|
182
182
|
context.eager_load(docs)
|
|
183
183
|
end
|
|
184
184
|
|
|
@@ -233,16 +233,16 @@ describe Mongoid::Relations::Eager do
|
|
|
233
233
|
Person.all.to_a
|
|
234
234
|
end
|
|
235
235
|
|
|
236
|
-
let(:
|
|
236
|
+
let(:book_association) do
|
|
237
237
|
Person.reflect_on_association(:book)
|
|
238
238
|
end
|
|
239
239
|
|
|
240
|
-
let(:
|
|
240
|
+
let(:cat_association) do
|
|
241
241
|
Person.reflect_on_association(:cat)
|
|
242
242
|
end
|
|
243
243
|
|
|
244
244
|
it "runs the has_one preload" do
|
|
245
|
-
expect(Mongoid::
|
|
245
|
+
expect(Mongoid::Association::Referenced::HasOne::Eager).to receive(:new).with([book_association, cat_association], docs).once.and_call_original
|
|
246
246
|
context.eager_load(docs)
|
|
247
247
|
end
|
|
248
248
|
end
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
describe Mongoid::
|
|
3
|
+
describe Mongoid::Association::Embedded::EmbeddedIn::Binding do
|
|
4
4
|
|
|
5
5
|
let(:person) do
|
|
6
6
|
Person.new
|
|
@@ -14,15 +14,15 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
|
14
14
|
Address.new
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
let(:
|
|
17
|
+
let(:name_association) do
|
|
18
18
|
Name.relations["namable"]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
let(:
|
|
21
|
+
let(:address_association) do
|
|
22
22
|
Address.relations["addressable"]
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
let(:
|
|
25
|
+
let(:person_association) do
|
|
26
26
|
Person.relations["addresses"]
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -31,7 +31,7 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
|
31
31
|
context "when the child of an embeds one" do
|
|
32
32
|
|
|
33
33
|
let(:binding) do
|
|
34
|
-
described_class.new(name, person,
|
|
34
|
+
described_class.new(name, person, name_association)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
context "when the document is bindable" do
|
|
@@ -65,12 +65,12 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
|
65
65
|
context "when the child of an embeds many" do
|
|
66
66
|
|
|
67
67
|
let(:binding) do
|
|
68
|
-
described_class.new(address, person,
|
|
68
|
+
described_class.new(address, person, address_association)
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
context "when the document is bindable" do
|
|
72
72
|
|
|
73
|
-
context "when the base has no
|
|
73
|
+
context "when the base has no association" do
|
|
74
74
|
|
|
75
75
|
before do
|
|
76
76
|
binding.bind_one
|
|
@@ -85,14 +85,14 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
context "when the base has
|
|
88
|
+
context "when the base has an association" do
|
|
89
89
|
|
|
90
90
|
before do
|
|
91
|
-
address.
|
|
91
|
+
address._association = person_association
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
it "does not overwrite the existing
|
|
95
|
-
expect(address).to receive(:
|
|
94
|
+
it "does not overwrite the existing association" do
|
|
95
|
+
expect(address).to receive(:_association=).never
|
|
96
96
|
binding.bind_one
|
|
97
97
|
end
|
|
98
98
|
end
|
|
@@ -117,7 +117,7 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
|
117
117
|
context "when the child of an embeds one" do
|
|
118
118
|
|
|
119
119
|
let(:binding) do
|
|
120
|
-
described_class.new(name, person,
|
|
120
|
+
described_class.new(name, person, name_association)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
context "when the document is unbindable" do
|
|
@@ -144,7 +144,7 @@ describe Mongoid::Relations::Bindings::Embedded::In do
|
|
|
144
144
|
context "when the child of an embeds many" do
|
|
145
145
|
|
|
146
146
|
let(:binding) do
|
|
147
|
-
described_class.new(address, person,
|
|
147
|
+
described_class.new(address, person, address_association)
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
context "when the document is unbindable" do
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
describe Mongoid::
|
|
3
|
+
describe Mongoid::Association::Embedded::EmbeddedIn::Buildable do
|
|
4
4
|
|
|
5
5
|
describe "#build" do
|
|
6
6
|
|
|
7
|
-
let(:
|
|
7
|
+
let(:base) do
|
|
8
8
|
double
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
let(:
|
|
12
|
-
|
|
11
|
+
let(:options) do
|
|
12
|
+
{ }
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
let(:
|
|
16
|
-
|
|
15
|
+
let(:association) do
|
|
16
|
+
Mongoid::Association::Embedded::EmbeddedIn.new(Person, :addresses, options)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
context "when a document is provided" do
|
|
20
20
|
|
|
21
|
-
let(:
|
|
22
|
-
|
|
21
|
+
let(:object) do
|
|
22
|
+
double
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
let(:document) do
|
|
26
|
-
|
|
26
|
+
association.build(base, object)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "returns the document" do
|
data/spec/mongoid/{relations/embedded/in_spec.rb → association/embedded/embedded_in/proxy_spec.rb}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
|
|
3
|
-
describe Mongoid::
|
|
3
|
+
describe Mongoid::Association::Embedded::EmbeddedIn::Proxy do
|
|
4
4
|
|
|
5
5
|
describe "#===" do
|
|
6
6
|
|
|
@@ -12,12 +12,12 @@ describe Mongoid::Relations::Embedded::In do
|
|
|
12
12
|
Person.new
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
let(:
|
|
15
|
+
let(:association) do
|
|
16
16
|
Name.relations["namable"]
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
let(:relation) do
|
|
20
|
-
described_class.new(base, target,
|
|
20
|
+
described_class.new(base, target, association)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
context "when the proxied document is same class" do
|
|
@@ -354,29 +354,6 @@ describe Mongoid::Relations::Embedded::In do
|
|
|
354
354
|
end
|
|
355
355
|
end
|
|
356
356
|
|
|
357
|
-
describe ".builder" do
|
|
358
|
-
|
|
359
|
-
let(:builder_klass) do
|
|
360
|
-
Mongoid::Relations::Builders::Embedded::In
|
|
361
|
-
end
|
|
362
|
-
|
|
363
|
-
let(:base) do
|
|
364
|
-
Name.new
|
|
365
|
-
end
|
|
366
|
-
|
|
367
|
-
let(:target) do
|
|
368
|
-
Person.new
|
|
369
|
-
end
|
|
370
|
-
|
|
371
|
-
let(:metadata) do
|
|
372
|
-
Name.relations["namable"]
|
|
373
|
-
end
|
|
374
|
-
|
|
375
|
-
it "returns the embedded one builder" do
|
|
376
|
-
expect(described_class.builder(base, metadata, target)).to be_a(builder_klass)
|
|
377
|
-
end
|
|
378
|
-
end
|
|
379
|
-
|
|
380
357
|
describe ".embedded?" do
|
|
381
358
|
|
|
382
359
|
it "returns true" do
|
|
@@ -384,39 +361,6 @@ describe Mongoid::Relations::Embedded::In do
|
|
|
384
361
|
end
|
|
385
362
|
end
|
|
386
363
|
|
|
387
|
-
describe ".foreign_key_suffix" do
|
|
388
|
-
|
|
389
|
-
it "returns nil" do
|
|
390
|
-
expect(described_class.foreign_key_suffix).to be_nil
|
|
391
|
-
end
|
|
392
|
-
end
|
|
393
|
-
|
|
394
|
-
describe ".macro" do
|
|
395
|
-
|
|
396
|
-
it "returns embeds_one" do
|
|
397
|
-
expect(described_class.macro).to eq(:embedded_in)
|
|
398
|
-
end
|
|
399
|
-
end
|
|
400
|
-
|
|
401
|
-
describe ".nested_builder" do
|
|
402
|
-
|
|
403
|
-
let(:nested_builder_klass) do
|
|
404
|
-
Mongoid::Relations::Builders::NestedAttributes::One
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
let(:metadata) do
|
|
408
|
-
Name.relations["namable"]
|
|
409
|
-
end
|
|
410
|
-
|
|
411
|
-
let(:attributes) do
|
|
412
|
-
{}
|
|
413
|
-
end
|
|
414
|
-
|
|
415
|
-
it "returns the single nested builder" do
|
|
416
|
-
expect(described_class.nested_builder(metadata, attributes, {})).to be_a(nested_builder_klass)
|
|
417
|
-
end
|
|
418
|
-
end
|
|
419
|
-
|
|
420
364
|
describe "#respond_to?" do
|
|
421
365
|
|
|
422
366
|
let(:person) do
|
|
@@ -442,22 +386,6 @@ describe Mongoid::Relations::Embedded::In do
|
|
|
442
386
|
end
|
|
443
387
|
end
|
|
444
388
|
|
|
445
|
-
describe ".valid_options" do
|
|
446
|
-
|
|
447
|
-
it "returns the valid options" do
|
|
448
|
-
expect(described_class.valid_options).to eq(
|
|
449
|
-
[ :autobuild, :cyclic, :polymorphic, :touch ]
|
|
450
|
-
)
|
|
451
|
-
end
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
describe ".validation_default" do
|
|
455
|
-
|
|
456
|
-
it "returns false" do
|
|
457
|
-
expect(described_class.validation_default).to be false
|
|
458
|
-
end
|
|
459
|
-
end
|
|
460
|
-
|
|
461
389
|
context "when creating the tree through initialization" do
|
|
462
390
|
|
|
463
391
|
let!(:person) do
|
|
@@ -494,8 +422,8 @@ describe Mongoid::Relations::Embedded::In do
|
|
|
494
422
|
|
|
495
423
|
it "has the locations in the association array" do
|
|
496
424
|
expect(Person.last.addresses.last.locations).to eq(
|
|
497
|
-
|
|
498
|
-
|
|
425
|
+
[first_location, second_location]
|
|
426
|
+
)
|
|
499
427
|
end
|
|
500
428
|
end
|
|
501
429
|
|
|
@@ -0,0 +1,843 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Mongoid::Association::Embedded::EmbeddedIn do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
class Container; include Mongoid::Document; end
|
|
7
|
+
class EmbeddedObject; include Mongoid::Document; end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after do
|
|
11
|
+
Object.send(:remove_const, :Container)
|
|
12
|
+
Object.send(:remove_const, :EmbeddedObject)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
let(:embedded_class) do
|
|
16
|
+
EmbeddedObject
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
let(:name) do
|
|
20
|
+
:container
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
let(:association) do
|
|
24
|
+
embedded_class.embedded_in name, options
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
let(:options) do
|
|
28
|
+
{ }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#VALID_OPTIONS' do
|
|
32
|
+
|
|
33
|
+
it 'returns the SHARED options with the ASSOCIATION_OPTIONS' do
|
|
34
|
+
expect(association.class::VALID_OPTIONS).to match_array(Mongoid::Association::Relatable::SHARED_OPTIONS +
|
|
35
|
+
association.class::ASSOCIATION_OPTIONS)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
describe '#relation_complements' do
|
|
40
|
+
|
|
41
|
+
let(:expected_complements) do
|
|
42
|
+
[
|
|
43
|
+
Mongoid::Association::Embedded::EmbedsMany,
|
|
44
|
+
Mongoid::Association::Embedded::EmbedsOne
|
|
45
|
+
]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'returns the relation complements' do
|
|
49
|
+
expect(association.send(:relation_complements)).to eq(expected_complements)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe '#setup_instance_methods!' do
|
|
54
|
+
|
|
55
|
+
it 'sets up a getter for the relation' do
|
|
56
|
+
expect(Mongoid::Association::Accessors).to receive(:define_getter!).with(association)
|
|
57
|
+
association.send(:setup_instance_methods!)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'sets up a setter for the relation' do
|
|
61
|
+
expect(Mongoid::Association::Accessors).to receive(:define_setter!).with(association)
|
|
62
|
+
association.send(:setup_instance_methods!)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'sets up an existence check for the relation' do
|
|
66
|
+
expect(Mongoid::Association::Accessors).to receive(:define_existence_check!).with(association)
|
|
67
|
+
association.send(:setup_instance_methods!)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe '#inverse_type_setter' do
|
|
72
|
+
|
|
73
|
+
context 'when polymorphic' do
|
|
74
|
+
|
|
75
|
+
let(:options) do
|
|
76
|
+
{ polymorphic: true }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'returns nil' do
|
|
80
|
+
expect(association.inverse_type).to be_nil
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context 'when not polymorphic' do
|
|
85
|
+
|
|
86
|
+
it 'returns nil' do
|
|
87
|
+
expect(association.inverse_type).to be_nil
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
describe '#embedded?' do
|
|
93
|
+
|
|
94
|
+
it 'returns true' do
|
|
95
|
+
expect(association.embedded?).to be(true)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
describe '#relation' do
|
|
100
|
+
|
|
101
|
+
it 'returns Mongoid::Association::Embedded::EmbeddedIn::Proxy' do
|
|
102
|
+
expect(association.relation).to be(Mongoid::Association::Embedded::EmbeddedIn::Proxy)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
describe '#validation_default' do
|
|
107
|
+
|
|
108
|
+
it 'returns false' do
|
|
109
|
+
expect(association.validation_default).to be(false)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe '#name' do
|
|
114
|
+
|
|
115
|
+
it 'returns the name of the relation' do
|
|
116
|
+
expect(association.name).to be(name)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
describe '#options' do
|
|
121
|
+
|
|
122
|
+
it 'returns the options' do
|
|
123
|
+
expect(association.options).to be(options)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
describe '#cyclic?' do
|
|
128
|
+
|
|
129
|
+
context 'when :cyclic is specified in the options' do
|
|
130
|
+
|
|
131
|
+
let(:options) do
|
|
132
|
+
{ cyclic: true }
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'returns true' do
|
|
136
|
+
expect(association.cyclic?).to be(true)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context 'when :cyclic is not specified in the options' do
|
|
141
|
+
|
|
142
|
+
it 'returns false' do
|
|
143
|
+
expect(association.cyclic?).to be(false)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
describe '#merge!' do
|
|
149
|
+
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
describe '#touchable?' do
|
|
154
|
+
|
|
155
|
+
context 'when :touch is in the options' do
|
|
156
|
+
|
|
157
|
+
let(:options) do
|
|
158
|
+
{ touch: true}
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it 'returns true' do
|
|
162
|
+
expect(association.send(:touchable?)).to be(true)
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
context 'when :touch is not in the options' do
|
|
167
|
+
|
|
168
|
+
it 'return false' do
|
|
169
|
+
expect(association.send(:touchable?)).to be(false)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
describe '#polymorphic?' do
|
|
175
|
+
|
|
176
|
+
context 'when :polymorphic is specified in the options as true' do
|
|
177
|
+
|
|
178
|
+
let(:options) do
|
|
179
|
+
{ polymorphic: true }
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it 'returns true' do
|
|
183
|
+
expect(association.polymorphic?).to be(true)
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
context 'when :polymorphic is specified in the options as false' do
|
|
188
|
+
|
|
189
|
+
let(:options) do
|
|
190
|
+
{ polymorphic: false }
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it 'returns false' do
|
|
194
|
+
expect(association.polymorphic?).to be(false)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
context 'when :polymorphic is not specified in the options' do
|
|
199
|
+
|
|
200
|
+
it 'returns false' do
|
|
201
|
+
expect(association.polymorphic?).to be(false)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
describe '#bindable?' do
|
|
207
|
+
|
|
208
|
+
it 'returns false' do
|
|
209
|
+
expect(association.bindable?(Person.new)).to be(false)
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
describe '#inverses' do
|
|
214
|
+
|
|
215
|
+
context 'when polymorphic' do
|
|
216
|
+
|
|
217
|
+
let(:options) do
|
|
218
|
+
{
|
|
219
|
+
polymorphic: true
|
|
220
|
+
}
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
let(:name) do
|
|
224
|
+
:containable
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
context 'when another object is passed to the method' do
|
|
228
|
+
|
|
229
|
+
let(:instance_of_other_class) do
|
|
230
|
+
Container.new
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
context 'when the relation class has only one relation whose class matches the owning class' do
|
|
234
|
+
|
|
235
|
+
before do
|
|
236
|
+
Container.embeds_many :embedded_objects, as: :containable
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
context 'when :inverse_of is specified' do
|
|
240
|
+
|
|
241
|
+
before do
|
|
242
|
+
options.merge!(inverse_of: :inverse_name)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'returns the :inverse_of value' do
|
|
246
|
+
expect(association.inverses(instance_of_other_class)).to eq([ :inverse_name ])
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
context 'when inverse_of is not specified' do
|
|
251
|
+
|
|
252
|
+
it 'returns the list of relations whose :as attribute matches the name of this association' do
|
|
253
|
+
expect(association.inverses(instance_of_other_class)).to match_array([ :embedded_objects ])
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
context 'when the relation class has two associations with the same name' do
|
|
257
|
+
|
|
258
|
+
before do
|
|
259
|
+
Container.embeds_many :embedded_objects, as: :containable
|
|
260
|
+
Container.embeds_many :other_embedded_objects, as: :containable
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
it 'returns only the relations whose :as attribute and class match' do
|
|
264
|
+
expect(association.inverses(instance_of_other_class)).to match_array([ :embedded_objects ])
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
context 'when the relation class has more than one relation whose class matches the owning class' do
|
|
271
|
+
|
|
272
|
+
before do
|
|
273
|
+
Container.embeds_many :embedded_objects, as: :containable
|
|
274
|
+
Container.embeds_one :other_embedded_object, as: :containable, class_name: 'EmbeddedObject'
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
context 'when :inverse_of is specified' do
|
|
278
|
+
|
|
279
|
+
before do
|
|
280
|
+
options.merge!(inverse_of: :inverse_name)
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
it 'returns the :inverse_of value' do
|
|
284
|
+
expect(association.inverses(instance_of_other_class)).to eq([ :inverse_name ])
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
context 'when inverse_of is not specified' do
|
|
289
|
+
|
|
290
|
+
it 'returns the list of relations whose :as attribute matches the name of this association' do
|
|
291
|
+
expect(association.inverses(instance_of_other_class)).to match_array([ :embedded_objects,
|
|
292
|
+
:other_embedded_object ])
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
context 'when another object is not passed to the method' do
|
|
299
|
+
|
|
300
|
+
context 'when inverse_of is specified' do
|
|
301
|
+
|
|
302
|
+
before do
|
|
303
|
+
options.merge!(inverse_of: :inverse_name)
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
it 'returns the :inverse_of value' do
|
|
307
|
+
expect(association.inverses).to eq([ :inverse_name ])
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
context 'when inverse_of is not specified' do
|
|
312
|
+
|
|
313
|
+
it 'returns nil' do
|
|
314
|
+
expect(association.inverses).to eq(nil)
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
context 'when not polymorphic' do
|
|
321
|
+
|
|
322
|
+
context 'when inverse_of is specified' do
|
|
323
|
+
|
|
324
|
+
before do
|
|
325
|
+
options.merge!(inverse_of: :inverse_name)
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
it 'returns the :inverse_of value' do
|
|
329
|
+
expect(association.inverses).to eq([ :inverse_name ])
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
context 'when inverse_of is not specified' do
|
|
334
|
+
|
|
335
|
+
before do
|
|
336
|
+
Container.embeds_many :embedded_objects
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
it 'uses the inverse class to find the inverse name' do
|
|
340
|
+
expect(association.inverses).to eq([ :embedded_objects ])
|
|
341
|
+
end
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
context 'when :cyclic is specified' do
|
|
345
|
+
|
|
346
|
+
it 'returns the cyclic inverse name' do
|
|
347
|
+
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
context 'when the inverse class has more than one relation with objects of the owner class' do
|
|
352
|
+
|
|
353
|
+
before do
|
|
354
|
+
Container.embeds_many :embedded_objects
|
|
355
|
+
Container.embeds_many :other_embedded_objects, class_name: 'EmbeddedObject'
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
it 'raises a Mongoid::Errors::AmbiguousRelationship exception' do
|
|
359
|
+
expect {
|
|
360
|
+
association.inverses
|
|
361
|
+
}.to raise_exception(Mongoid::Errors::AmbiguousRelationship)
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
context 'when the inverse class only has one relation with objects of the owner class' do
|
|
366
|
+
|
|
367
|
+
before do
|
|
368
|
+
Container.embeds_many :embedded_objects
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
it 'uses the inverse class to find the inverse name' do
|
|
372
|
+
expect(association.inverses).to eq([ :embedded_objects ])
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
describe '#inverse' do
|
|
379
|
+
|
|
380
|
+
context 'when polymorphic' do
|
|
381
|
+
|
|
382
|
+
let(:options) do
|
|
383
|
+
{
|
|
384
|
+
polymorphic: true
|
|
385
|
+
}
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
let(:name) do
|
|
389
|
+
:containable
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
context 'when another object is passed to the method' do
|
|
393
|
+
|
|
394
|
+
let(:instance_of_other_class) do
|
|
395
|
+
Container.new
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
context 'when the relation class has only one relation whose class matches the owning class' do
|
|
399
|
+
|
|
400
|
+
before do
|
|
401
|
+
Container.embeds_many :embedded_objects, as: :containable
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
context 'when :inverse_of is specified' do
|
|
405
|
+
|
|
406
|
+
before do
|
|
407
|
+
options.merge!(inverse_of: :inverse_name)
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
it 'returns the :inverse_of value' do
|
|
411
|
+
expect(association.inverse(instance_of_other_class)).to eq(:inverse_name)
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
context 'when inverse_of is not specified' do
|
|
416
|
+
|
|
417
|
+
it 'returns the list of relations whose :as attribute matches the name of this association' do
|
|
418
|
+
expect(association.inverse(instance_of_other_class)).to eq(:embedded_objects)
|
|
419
|
+
end
|
|
420
|
+
end
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
context 'when the relation class has more than one relation whose class matches the owning class' do
|
|
424
|
+
|
|
425
|
+
before do
|
|
426
|
+
Container.embeds_many :embedded_objects, as: :containable
|
|
427
|
+
Container.embeds_one :other_embedded_object, as: :containable
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
context 'when :inverse_of is specified' do
|
|
431
|
+
|
|
432
|
+
before do
|
|
433
|
+
options.merge!(inverse_of: :inverse_name)
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
it 'returns the :inverse_of value' do
|
|
437
|
+
expect(association.inverse(instance_of_other_class)).to eq(:inverse_name)
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
context 'when inverse_of is not specified' do
|
|
442
|
+
|
|
443
|
+
it 'returns the first candidate whose :as attribute matches the name of this association' do
|
|
444
|
+
expect(association.inverse(instance_of_other_class)).to eq(:embedded_objects)
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
context 'when another object is not passed to the method' do
|
|
451
|
+
|
|
452
|
+
context 'when inverse_of is specified' do
|
|
453
|
+
|
|
454
|
+
before do
|
|
455
|
+
options.merge!(inverse_of: :inverse_name)
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it 'returns the :inverse_of value' do
|
|
459
|
+
expect(association.inverse).to eq(:inverse_name)
|
|
460
|
+
end
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
context 'when inverse_of is not specified' do
|
|
464
|
+
|
|
465
|
+
it 'returns nil' do
|
|
466
|
+
expect(association.inverse).to eq(nil)
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
context 'when not polymorphic' do
|
|
473
|
+
|
|
474
|
+
context 'when inverse_of is specified' do
|
|
475
|
+
|
|
476
|
+
before do
|
|
477
|
+
options.merge!(inverse_of: :inverse_name)
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
it 'returns the :inverse_of value' do
|
|
481
|
+
expect(association.inverse).to eq(:inverse_name)
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
context 'when inverse_of is not specified' do
|
|
486
|
+
|
|
487
|
+
before do
|
|
488
|
+
Container.embeds_many :embedded_objects
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
it 'uses the inverse class to find the inverse name' do
|
|
492
|
+
expect(association.inverse).to eq(:embedded_objects)
|
|
493
|
+
end
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
context 'when :cyclic is specified' do
|
|
497
|
+
|
|
498
|
+
it 'returns the cyclic inverse name' do
|
|
499
|
+
|
|
500
|
+
end
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
context 'when the inverse class has more than one relation with objects of the owner class' do
|
|
504
|
+
|
|
505
|
+
before do
|
|
506
|
+
Container.embeds_many :embedded_objects
|
|
507
|
+
Container.embeds_many :other_embedded_objects, class_name: 'EmbeddedObject'
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
it 'raises a Mongoid::Errors::AmbiguousRelationship exception' do
|
|
511
|
+
expect {
|
|
512
|
+
association.inverse
|
|
513
|
+
}.to raise_exception(Mongoid::Errors::AmbiguousRelationship)
|
|
514
|
+
end
|
|
515
|
+
end
|
|
516
|
+
|
|
517
|
+
context 'when the inverse class only has one relation with objects of the owner class' do
|
|
518
|
+
|
|
519
|
+
before do
|
|
520
|
+
Container.embeds_many :embedded_objects
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
it 'uses the inverse class to find the inverse name' do
|
|
524
|
+
expect(association.inverse).to eq(:embedded_objects)
|
|
525
|
+
end
|
|
526
|
+
end
|
|
527
|
+
end
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
describe '#inverse_association' do
|
|
531
|
+
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
describe '#autosave' do
|
|
535
|
+
|
|
536
|
+
it 'returns false' do
|
|
537
|
+
expect(association.autosave).to be(false)
|
|
538
|
+
end
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
describe '#relation_class_name' do
|
|
542
|
+
|
|
543
|
+
context 'when the :class_name option is specified' do
|
|
544
|
+
|
|
545
|
+
let(:options) do
|
|
546
|
+
{ class_name: 'OtherContainer' }
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
it 'returns the class name option' do
|
|
550
|
+
expect(association.relation_class_name).to eq('OtherContainer')
|
|
551
|
+
end
|
|
552
|
+
end
|
|
553
|
+
|
|
554
|
+
context 'when the class_name option is not specified' do
|
|
555
|
+
|
|
556
|
+
it 'uses the name of the relation to deduce the class name' do
|
|
557
|
+
expect(association.relation_class_name).to eq('Container')
|
|
558
|
+
end
|
|
559
|
+
end
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
describe '#klass' do
|
|
563
|
+
|
|
564
|
+
context 'when the :class_name option is specified' do
|
|
565
|
+
|
|
566
|
+
let!(:_class) do
|
|
567
|
+
class OtherContainer; end
|
|
568
|
+
OtherContainer
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
let(:options) do
|
|
572
|
+
{ class_name: 'OtherContainer' }
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
it 'returns the class name option' do
|
|
576
|
+
expect(association.klass).to eq(_class)
|
|
577
|
+
end
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
context 'when the class_name option is not specified' do
|
|
581
|
+
|
|
582
|
+
it 'uses the name of the relation to deduce the class name' do
|
|
583
|
+
expect(association.klass).to eq(Container)
|
|
584
|
+
end
|
|
585
|
+
end
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
describe '#inverse_class_name' do
|
|
589
|
+
|
|
590
|
+
it 'returns the name of the owner class' do
|
|
591
|
+
expect(association.inverse_class_name).to eq(embedded_class.name)
|
|
592
|
+
end
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
describe '#inverse_class' do
|
|
596
|
+
|
|
597
|
+
it 'returns the owner class' do
|
|
598
|
+
expect(association.inverse_class).to be(embedded_class)
|
|
599
|
+
end
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
describe '#inverse_of' do
|
|
603
|
+
|
|
604
|
+
context 'when :inverse_of is specified in the options' do
|
|
605
|
+
|
|
606
|
+
let(:options) do
|
|
607
|
+
{ inverse_of: :a_container }
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
it 'returns the inverse_of value' do
|
|
611
|
+
expect(association.inverse_of).to eq(options[:inverse_of])
|
|
612
|
+
end
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
context 'when :inverse_of is not specified in the options' do
|
|
616
|
+
|
|
617
|
+
it 'returns nil' do
|
|
618
|
+
expect(association.inverse_of).to be_nil
|
|
619
|
+
end
|
|
620
|
+
end
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
describe '#key' do
|
|
624
|
+
|
|
625
|
+
it 'returns the name of the relation as a string' do
|
|
626
|
+
expect(association.key).to eq(name.to_s)
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
|
|
630
|
+
describe '#setter' do
|
|
631
|
+
|
|
632
|
+
it 'returns a string of the name followed by =' do
|
|
633
|
+
expect(association.setter).to eq("#{name}=")
|
|
634
|
+
end
|
|
635
|
+
end
|
|
636
|
+
|
|
637
|
+
describe '#validate?' do
|
|
638
|
+
|
|
639
|
+
context 'when :validate is specified in the options' do
|
|
640
|
+
|
|
641
|
+
context 'when validate is true' do
|
|
642
|
+
|
|
643
|
+
let(:options) do
|
|
644
|
+
{ validate: true }
|
|
645
|
+
end
|
|
646
|
+
|
|
647
|
+
it 'returns true' do
|
|
648
|
+
expect(association.send(:validate?)).to be(true)
|
|
649
|
+
end
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
context 'when validate is false' do
|
|
653
|
+
|
|
654
|
+
let(:options) do
|
|
655
|
+
{ validate: false }
|
|
656
|
+
end
|
|
657
|
+
|
|
658
|
+
it 'returns false' do
|
|
659
|
+
expect(association.send(:validate?)).to be(false)
|
|
660
|
+
end
|
|
661
|
+
end
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
context 'when :validate is not specified in the options' do
|
|
665
|
+
|
|
666
|
+
it 'returns the validation_default' do
|
|
667
|
+
expect(association.send(:validate?)).to eq(association.validation_default)
|
|
668
|
+
end
|
|
669
|
+
end
|
|
670
|
+
end
|
|
671
|
+
|
|
672
|
+
describe '#autobuilding?' do
|
|
673
|
+
|
|
674
|
+
context 'when :autobuild is specified in the options' do
|
|
675
|
+
|
|
676
|
+
context 'when autobuild is true' do
|
|
677
|
+
|
|
678
|
+
let(:options) do
|
|
679
|
+
{ autobuild: true }
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
it 'returns true' do
|
|
683
|
+
expect(association.autobuilding?).to be(true)
|
|
684
|
+
end
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
context 'when autobuild is false' do
|
|
688
|
+
|
|
689
|
+
let(:options) do
|
|
690
|
+
{ autobuild: false }
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
it 'returns true' do
|
|
694
|
+
expect(association.autobuilding?).to be(false)
|
|
695
|
+
end
|
|
696
|
+
end
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
context 'when :validate is not specified in the options' do
|
|
700
|
+
|
|
701
|
+
it 'returns false' do
|
|
702
|
+
expect(association.autobuilding?).to be(false)
|
|
703
|
+
end
|
|
704
|
+
end
|
|
705
|
+
end
|
|
706
|
+
|
|
707
|
+
describe '#forced_nil_inverse?' do
|
|
708
|
+
|
|
709
|
+
it 'returns false' do
|
|
710
|
+
expect(association.forced_nil_inverse?).to be(false)
|
|
711
|
+
end
|
|
712
|
+
end
|
|
713
|
+
|
|
714
|
+
describe '#stores_foreign_key?' do
|
|
715
|
+
|
|
716
|
+
it 'returns false' do
|
|
717
|
+
expect(association.stores_foreign_key?).to be(false)
|
|
718
|
+
end
|
|
719
|
+
end
|
|
720
|
+
|
|
721
|
+
describe '#inverse_setter' do
|
|
722
|
+
|
|
723
|
+
context 'when an inverse can be determined' do
|
|
724
|
+
|
|
725
|
+
before do
|
|
726
|
+
Container.embeds_many :embedded_objects
|
|
727
|
+
end
|
|
728
|
+
|
|
729
|
+
it 'returns the name of the inverse followed by =' do
|
|
730
|
+
expect(association.inverse_setter).to eq('embedded_objects=')
|
|
731
|
+
end
|
|
732
|
+
end
|
|
733
|
+
|
|
734
|
+
context 'when an inverse cannot be determined' do
|
|
735
|
+
|
|
736
|
+
it 'returns nil' do
|
|
737
|
+
expect(association.inverse_setter).to be_nil
|
|
738
|
+
end
|
|
739
|
+
end
|
|
740
|
+
end
|
|
741
|
+
|
|
742
|
+
describe '#extension' do
|
|
743
|
+
|
|
744
|
+
context 'when a block is passed' do
|
|
745
|
+
|
|
746
|
+
let(:association) do
|
|
747
|
+
embedded_class.embedded_in name, options do; end
|
|
748
|
+
end
|
|
749
|
+
|
|
750
|
+
it 'defines an extension module' do
|
|
751
|
+
expect(association.extension).to be_a(Module)
|
|
752
|
+
end
|
|
753
|
+
|
|
754
|
+
it 'returns the extension' do
|
|
755
|
+
expect(association.extension).to eq(
|
|
756
|
+
"#{embedded_class.name}::#{embedded_class.name}#{name.capitalize}RelationExtension".constantize)
|
|
757
|
+
end
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
context 'when an :extension is not specified in the options' do
|
|
761
|
+
|
|
762
|
+
it 'returns false' do
|
|
763
|
+
expect(association.extension).to be_nil
|
|
764
|
+
end
|
|
765
|
+
end
|
|
766
|
+
end
|
|
767
|
+
|
|
768
|
+
describe '#criteria' do
|
|
769
|
+
|
|
770
|
+
it 'does not respond to the method' do
|
|
771
|
+
expect {
|
|
772
|
+
association.criteria
|
|
773
|
+
}.to raise_exception(NoMethodError)
|
|
774
|
+
end
|
|
775
|
+
end
|
|
776
|
+
|
|
777
|
+
describe '#destructive?' do
|
|
778
|
+
|
|
779
|
+
it 'returns false' do
|
|
780
|
+
expect(association.destructive?).to be(false)
|
|
781
|
+
end
|
|
782
|
+
end
|
|
783
|
+
|
|
784
|
+
describe '#nested_builder' do
|
|
785
|
+
|
|
786
|
+
it 'returns an instance of Association::Nested::One' do
|
|
787
|
+
expect(association.nested_builder({}, {})).to be_a(Mongoid::Association::Nested::One)
|
|
788
|
+
end
|
|
789
|
+
end
|
|
790
|
+
|
|
791
|
+
describe '#cascading_callbacks?' do
|
|
792
|
+
|
|
793
|
+
context 'when cascade_callbacks is specified in the options' do
|
|
794
|
+
|
|
795
|
+
let(:options) do
|
|
796
|
+
{cascade_callbacks: true}
|
|
797
|
+
end
|
|
798
|
+
|
|
799
|
+
it 'raises a Mongoid::Errors::InvalidRelationOption exception' do
|
|
800
|
+
expect {
|
|
801
|
+
association.cascading_callbacks?
|
|
802
|
+
}.to raise_exception(Mongoid::Errors::InvalidRelationOption)
|
|
803
|
+
end
|
|
804
|
+
end
|
|
805
|
+
|
|
806
|
+
context 'when cascade_callbacks is not specified in the options' do
|
|
807
|
+
|
|
808
|
+
it 'returns false' do
|
|
809
|
+
expect(association.cascading_callbacks?).to be(false)
|
|
810
|
+
end
|
|
811
|
+
end
|
|
812
|
+
end
|
|
813
|
+
|
|
814
|
+
describe '#path' do
|
|
815
|
+
|
|
816
|
+
it 'returns an instance of Mongoid::Atomic::Paths::Root' do
|
|
817
|
+
expect(association.path({})).to be_a(Mongoid::Atomic::Paths::Root)
|
|
818
|
+
end
|
|
819
|
+
end
|
|
820
|
+
|
|
821
|
+
describe '#foreign_key_check' do
|
|
822
|
+
|
|
823
|
+
it 'returns nil' do
|
|
824
|
+
expect(association.foreign_key_check).to be_nil
|
|
825
|
+
end
|
|
826
|
+
end
|
|
827
|
+
|
|
828
|
+
describe '#create_relation' do
|
|
829
|
+
|
|
830
|
+
let(:owner) do
|
|
831
|
+
Container.new
|
|
832
|
+
end
|
|
833
|
+
|
|
834
|
+
let(:target) do
|
|
835
|
+
EmbeddedObject.new
|
|
836
|
+
end
|
|
837
|
+
|
|
838
|
+
it 'returns an instance of Mongoid::Association::Embedded::EmbeddedIn::Proxy' do
|
|
839
|
+
expect(Mongoid::Association::Embedded::EmbeddedIn::Proxy).to receive(:new).and_call_original
|
|
840
|
+
expect(association.create_relation(owner, target)).to be_a(EmbeddedObject)
|
|
841
|
+
end
|
|
842
|
+
end
|
|
843
|
+
end
|