mongoid 6.4.8 → 7.0.13
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/LICENSE +1 -0
- data/README.md +4 -3
- data/Rakefile +33 -7
- 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 +211 -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 +174 -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 +45 -59
- 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 +511 -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/paths/embedded.rb +1 -1
- data/lib/mongoid/atomic.rb +14 -4
- data/lib/mongoid/attributes/dynamic.rb +16 -15
- 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 +55 -31
- data/lib/mongoid/changeable.rb +1 -1
- data/lib/mongoid/clients/options.rb +7 -5
- data/lib/mongoid/clients/sessions.rb +20 -4
- data/lib/mongoid/composable.rb +4 -4
- data/lib/mongoid/config/environment.rb +21 -8
- 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 +11 -6
- data/lib/mongoid/criteria/includable.rb +14 -14
- data/lib/mongoid/criteria/modifiable.rb +8 -3
- data/lib/mongoid/criteria/options.rb +2 -2
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/regexp.rb +3 -3
- data/lib/mongoid/criteria/queryable/extensions/string.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/time.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +12 -0
- data/lib/mongoid/criteria/queryable/key.rb +67 -8
- data/lib/mongoid/criteria/queryable/mergeable.rb +5 -4
- data/lib/mongoid/criteria/queryable/pipeline.rb +10 -5
- data/lib/mongoid/criteria/queryable/selectable.rb +5 -3
- data/lib/mongoid/criteria/queryable/selector.rb +9 -31
- data/lib/mongoid/criteria.rb +9 -3
- data/lib/mongoid/document.rb +14 -4
- 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/hash.rb +9 -4
- data/lib/mongoid/extensions/object.rb +4 -4
- data/lib/mongoid/extensions/range.rb +1 -0
- data/lib/mongoid/extensions/regexp.rb +1 -1
- data/lib/mongoid/extensions/string.rb +2 -2
- 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 +5 -4
- data/lib/mongoid/indexable.rb +4 -1
- data/lib/mongoid/interceptable.rb +8 -6
- data/lib/mongoid/matchable/all.rb +4 -3
- data/lib/mongoid/matchable/and.rb +1 -1
- data/lib/mongoid/matchable/default.rb +71 -24
- 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/regexp.rb +2 -2
- data/lib/mongoid/matchable.rb +17 -16
- 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/pushable.rb +11 -2
- data/lib/mongoid/persistable/settable.rb +57 -12
- data/lib/mongoid/persistable.rb +4 -5
- data/lib/mongoid/persistence_context.rb +26 -11
- data/lib/mongoid/positional.rb +1 -1
- data/lib/mongoid/query_cache.rb +4 -2
- data/lib/mongoid/serializable.rb +4 -4
- data/lib/mongoid/shardable.rb +1 -1
- data/lib/mongoid/touchable.rb +102 -0
- data/lib/mongoid/traversable.rb +3 -3
- data/lib/mongoid/validatable/macros.rb +1 -1
- data/lib/mongoid/validatable/presence.rb +2 -2
- data/lib/mongoid/validatable/uniqueness.rb +5 -5
- data/lib/mongoid/validatable.rb +8 -8
- data/lib/mongoid/version.rb +2 -1
- data/lib/mongoid.rb +1 -0
- data/lib/rails/generators/mongoid/config/config_generator.rb +8 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +3 -0
- data/lib/rails/generators/mongoid/model/templates/model.rb.tt +1 -1
- data/spec/README.md +18 -0
- data/spec/app/models/animal.rb +2 -1
- data/spec/app/models/bomb.rb +1 -1
- data/spec/app/models/customer.rb +11 -0
- data/spec/app/models/customer_address.rb +12 -0
- data/spec/app/models/message.rb +1 -1
- data/spec/app/models/minim.rb +7 -0
- data/spec/app/models/other_owner_object.rb +2 -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/app_spec.rb +341 -0
- data/spec/integration/associations/belongs_to_spec.rb +13 -0
- data/spec/integration/associations/embedded_spec.rb +176 -0
- data/spec/integration/callbacks_models.rb +49 -0
- data/spec/integration/callbacks_spec.rb +216 -0
- data/spec/integration/criteria/date_field_spec.rb +41 -0
- data/spec/integration/criteria/time_with_zone_spec.rb +32 -0
- data/spec/integration/matchable_spec.rb +680 -0
- data/spec/lite_spec_helper.rb +71 -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 → 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} +55 -77
- data/spec/mongoid/association/embedded/embedded_in_spec.rb +901 -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_models.rb +53 -0
- data/spec/mongoid/association/embedded/embeds_many_spec.rb +862 -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_dnl_models.rb +6 -0
- data/spec/mongoid/association/embedded/embeds_one_models.rb +51 -0
- data/spec/mongoid/association/embedded/embeds_one_spec.rb +954 -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 +2023 -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} +247 -99
- 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 +227 -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} +30 -94
- 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 +1360 -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/paths_spec.rb +41 -0
- data/spec/mongoid/atomic_spec.rb +4 -4
- data/spec/mongoid/attributes/dynamic_spec.rb +153 -0
- data/spec/mongoid/attributes/nested_spec.rb +29 -11
- data/spec/mongoid/attributes/readonly_spec.rb +80 -125
- data/spec/mongoid/attributes_spec.rb +298 -9
- data/spec/mongoid/clients/factory_spec.rb +20 -38
- data/spec/mongoid/clients/options_spec.rb +64 -50
- data/spec/mongoid/clients/sessions_spec.rb +9 -5
- data/spec/mongoid/clients/transactions_spec.rb +390 -0
- data/spec/mongoid/clients_spec.rb +70 -10
- data/spec/mongoid/config_spec.rb +27 -1
- data/spec/mongoid/contextual/atomic_spec.rb +37 -14
- data/spec/mongoid/contextual/geo_near_spec.rb +11 -2
- data/spec/mongoid/contextual/map_reduce_spec.rb +20 -5
- data/spec/mongoid/contextual/memory_spec.rb +19 -0
- data/spec/mongoid/contextual/mongo_spec.rb +107 -56
- data/spec/mongoid/copyable_spec.rb +90 -6
- data/spec/mongoid/copyable_spec_models.rb +17 -0
- data/spec/mongoid/criteria/modifiable_spec.rb +173 -1
- data/spec/mongoid/criteria/queryable/extensions/numeric_spec.rb +54 -0
- data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +7 -7
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +44 -1
- data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +19 -7
- data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +28 -1
- data/spec/mongoid/criteria/queryable/key_spec.rb +48 -6
- data/spec/mongoid/criteria/queryable/pipeline_spec.rb +12 -0
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +762 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +5 -224
- data/spec/mongoid/criteria/queryable/selector_spec.rb +37 -0
- data/spec/mongoid/criteria_spec.rb +36 -19
- data/spec/mongoid/document_fields_spec.rb +88 -0
- data/spec/mongoid/document_persistence_context_spec.rb +33 -0
- data/spec/mongoid/document_spec.rb +29 -4
- data/spec/mongoid/extensions/array_spec.rb +11 -15
- 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/factory_spec.rb +21 -3
- data/spec/mongoid/fields/foreign_key_spec.rb +24 -32
- data/spec/mongoid/fields_spec.rb +1 -1
- data/spec/mongoid/indexable_spec.rb +24 -12
- data/spec/mongoid/interceptable_spec.rb +22 -1
- data/spec/mongoid/matchable/default_spec.rb +10 -3
- data/spec/mongoid/matchable/elem_match_spec.rb +20 -0
- data/spec/mongoid/matchable/eq_spec.rb +48 -0
- data/spec/mongoid/matchable/regexp_spec.rb +2 -2
- data/spec/mongoid/matchable_spec.rb +2 -2
- data/spec/mongoid/persistable/pushable_spec.rb +55 -1
- data/spec/mongoid/persistable/savable_spec.rb +5 -5
- data/spec/mongoid/persistable/settable_spec.rb +125 -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 +65 -27
- data/spec/mongoid/relations/proxy_spec.rb +124 -124
- data/spec/mongoid/scopable_spec.rb +2 -1
- data/spec/mongoid/shardable_spec.rb +32 -12
- data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
- data/spec/mongoid/tasks/database_spec.rb +1 -1
- 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/uniqueness_spec.rb +33 -6
- data/spec/mongoid/validatable_spec.rb +1 -1
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +221 -0
- data/spec/shared/lib/mrss/constraints.rb +354 -0
- data/spec/shared/lib/mrss/docker_runner.rb +265 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +191 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +115 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +162 -0
- data/spec/shared/lib/mrss/utils.rb +15 -0
- data/spec/shared/share/Dockerfile.erb +231 -0
- data/spec/shared/shlib/distro.sh +73 -0
- data/spec/shared/shlib/server.sh +290 -0
- data/spec/shared/shlib/set_env.sh +128 -0
- data/spec/spec_helper.rb +34 -49
- data/spec/support/cluster_config.rb +3 -3
- data/spec/support/constraints.rb +21 -76
- data/spec/support/expectations.rb +17 -3
- data/spec/support/spec_config.rb +20 -7
- data.tar.gz.sig +0 -0
- metadata +646 -541
- metadata.gz.sig +1 -5
- 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
|
@@ -42,7 +42,7 @@ describe Mongoid::Attributes do
|
|
|
42
42
|
context "accessing via []" do
|
|
43
43
|
|
|
44
44
|
it "does not raise an error" do
|
|
45
|
-
expect(from_db["desc"]).to eq("
|
|
45
|
+
expect(from_db["desc"]).to eq("test")
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -150,6 +150,17 @@ describe Mongoid::Attributes do
|
|
|
150
150
|
|
|
151
151
|
describe "#[]" do
|
|
152
152
|
|
|
153
|
+
context 'when the document has a custom attribute type' do
|
|
154
|
+
|
|
155
|
+
let(:bar) do
|
|
156
|
+
Bar.create(lat_lng: LatLng.new(52.30, 13.25))
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'returns the demongoized version of the attribute' do
|
|
160
|
+
expect(bar.reload[:lat_lng]).to be_a(LatLng)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
153
164
|
context "when the document is a new record" do
|
|
154
165
|
|
|
155
166
|
let(:person) do
|
|
@@ -165,7 +176,7 @@ describe Mongoid::Attributes do
|
|
|
165
176
|
context "when passing just the name" do
|
|
166
177
|
|
|
167
178
|
it "returns the full value" do
|
|
168
|
-
expect(person[:desc]).to eq("
|
|
179
|
+
expect(person[:desc]).to eq("testing")
|
|
169
180
|
end
|
|
170
181
|
end
|
|
171
182
|
|
|
@@ -231,6 +242,97 @@ describe Mongoid::Attributes do
|
|
|
231
242
|
end
|
|
232
243
|
end
|
|
233
244
|
|
|
245
|
+
context "when the field was not explicitly defined" do
|
|
246
|
+
|
|
247
|
+
context "when excluding with only and the field was not excluded" do
|
|
248
|
+
|
|
249
|
+
let(:from_db) do
|
|
250
|
+
Person.only(:_id).first
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
it "raises an error" do
|
|
254
|
+
expect {
|
|
255
|
+
from_db[:undefined_field]
|
|
256
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
context "when excluding with without and the field was excluded" do
|
|
261
|
+
|
|
262
|
+
let(:from_db) do
|
|
263
|
+
Person.without(:title).first
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
it "raises an error" do
|
|
267
|
+
expect {
|
|
268
|
+
from_db[:title]
|
|
269
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
|
270
|
+
end
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
context "when excluding with without and the field was not excluded" do
|
|
274
|
+
|
|
275
|
+
let(:from_db) do
|
|
276
|
+
Person.without(:title).first
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
it "returns nil" do
|
|
280
|
+
from_db[:undefined_field].should be nil
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
context 'when projecting with #only' do
|
|
286
|
+
let!(:person) do
|
|
287
|
+
Person.create(title: 'sir', name: { first_name: 'Jose', language: { name: 'es' } })
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
context 'when projecting an embedded association' do
|
|
291
|
+
let(:from_db) do
|
|
292
|
+
Person.only(:name).first
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
context 'when retrieving a field of the association using the dot notation' do
|
|
296
|
+
|
|
297
|
+
it 'retrieves the field' do
|
|
298
|
+
pending 'MONGOID-5032, fixed in 7.3'
|
|
299
|
+
|
|
300
|
+
expect(from_db['name.first_name']).to eq 'Jose'
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
context 'when retrieving a field of a nested association using the dot notation' do
|
|
305
|
+
it 'retrieves the field' do
|
|
306
|
+
pending 'MONGOID-5032, fixed in 7.3'
|
|
307
|
+
|
|
308
|
+
expect(from_db['name.language.name']).to eq 'es'
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
context 'when projecting a sub-association of an embedded association' do
|
|
314
|
+
let(:from_db) do
|
|
315
|
+
Person.only('name.language').first
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
context 'when retrieving a field under the projected sub-association' do
|
|
319
|
+
it 'retrieves the field' do
|
|
320
|
+
pending 'MONGOID-5032, fixed in 7.3'
|
|
321
|
+
|
|
322
|
+
expect(from_db['name.language.name']).to eq 'es'
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
context 'when retrieving a non-projected field' do
|
|
327
|
+
it 'raises MissingAttributeError' do
|
|
328
|
+
expect do
|
|
329
|
+
from_db['name.first_name']
|
|
330
|
+
end.to raise_error(ActiveModel::MissingAttributeError)
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
234
336
|
context "when the attribute does not exist" do
|
|
235
337
|
|
|
236
338
|
before do
|
|
@@ -268,6 +370,20 @@ describe Mongoid::Attributes do
|
|
|
268
370
|
|
|
269
371
|
describe "#[]=" do
|
|
270
372
|
|
|
373
|
+
context 'when the document has a custom attribute type' do
|
|
374
|
+
|
|
375
|
+
let(:bar) do
|
|
376
|
+
Bar.new.tap do |b|
|
|
377
|
+
b[:lat_lng] = LatLng.new(52.30, 13.25)
|
|
378
|
+
b.save
|
|
379
|
+
end
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
it 'sets the demongoized version of the attribute' do
|
|
383
|
+
expect(bar.reload.lat_lng).to be_a(LatLng)
|
|
384
|
+
end
|
|
385
|
+
end
|
|
386
|
+
|
|
271
387
|
let(:person) do
|
|
272
388
|
Person.new
|
|
273
389
|
end
|
|
@@ -301,6 +417,67 @@ describe Mongoid::Attributes do
|
|
|
301
417
|
expect(terms).to eq(true)
|
|
302
418
|
end
|
|
303
419
|
end
|
|
420
|
+
|
|
421
|
+
context 'when the field is not explicitly defined' do
|
|
422
|
+
let(:bar) { Bar.new }
|
|
423
|
+
|
|
424
|
+
before do
|
|
425
|
+
bar['missing_field'] = 42
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
it 'writes the value into attributes' do
|
|
429
|
+
bar.attributes.should == {'_id' => bar.id, 'missing_field' => 42}
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
it 'makes the attribute accessible via []' do
|
|
433
|
+
bar['missing_field'].should == 42
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
context 'when writing fields on a document with projection' do
|
|
437
|
+
|
|
438
|
+
let!(:person) do
|
|
439
|
+
Person.create(title: "sir")
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
context "when excluding with only and the field was not excluded" do
|
|
443
|
+
|
|
444
|
+
let(:from_db) do
|
|
445
|
+
Person.only(:_id).first
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
it "raises an error" do
|
|
449
|
+
expect {
|
|
450
|
+
from_db[:undefined_field] = 'x'
|
|
451
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
context "when excluding with without and the field was excluded" do
|
|
456
|
+
|
|
457
|
+
let(:from_db) do
|
|
458
|
+
Person.without(:title).first
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
it "raises an error" do
|
|
462
|
+
expect {
|
|
463
|
+
from_db[:title] = 'x'
|
|
464
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
|
465
|
+
end
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
context "when excluding with without and the field was not excluded" do
|
|
469
|
+
|
|
470
|
+
let(:from_db) do
|
|
471
|
+
Person.without(:title).first
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
it "writes the value" do
|
|
475
|
+
from_db[:undefined_field] = 'x'
|
|
476
|
+
from_db[:undefined_field].should == 'x'
|
|
477
|
+
end
|
|
478
|
+
end
|
|
479
|
+
end
|
|
480
|
+
end
|
|
304
481
|
end
|
|
305
482
|
|
|
306
483
|
describe "#_id" do
|
|
@@ -768,6 +945,17 @@ describe Mongoid::Attributes do
|
|
|
768
945
|
|
|
769
946
|
describe "#read_attribute" do
|
|
770
947
|
|
|
948
|
+
context 'when the document has a custom attribute type' do
|
|
949
|
+
|
|
950
|
+
let(:bar) do
|
|
951
|
+
Bar.create(lat_lng: LatLng.new(52.30, 13.25))
|
|
952
|
+
end
|
|
953
|
+
|
|
954
|
+
it 'returns the demongoized version of the attribute' do
|
|
955
|
+
expect(bar.reload.read_attribute(:lat_lng)).to be_a(LatLng)
|
|
956
|
+
end
|
|
957
|
+
end
|
|
958
|
+
|
|
771
959
|
context "when the document is a new record" do
|
|
772
960
|
|
|
773
961
|
let(:person) do
|
|
@@ -854,6 +1042,50 @@ describe Mongoid::Attributes do
|
|
|
854
1042
|
expect(person.age_before_type_cast).to eq("old")
|
|
855
1043
|
end
|
|
856
1044
|
end
|
|
1045
|
+
|
|
1046
|
+
context 'when reading fields on a document with projection' do
|
|
1047
|
+
|
|
1048
|
+
let!(:person) do
|
|
1049
|
+
Person.create(title: "sir")
|
|
1050
|
+
end
|
|
1051
|
+
|
|
1052
|
+
context "when excluding with only and the field was not excluded" do
|
|
1053
|
+
|
|
1054
|
+
let(:from_db) do
|
|
1055
|
+
Person.only(:_id).first
|
|
1056
|
+
end
|
|
1057
|
+
|
|
1058
|
+
it "raises an error" do
|
|
1059
|
+
expect {
|
|
1060
|
+
from_db.read_attribute(:undefined_field)
|
|
1061
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
|
1062
|
+
end
|
|
1063
|
+
end
|
|
1064
|
+
|
|
1065
|
+
context "when excluding with without and the field was excluded" do
|
|
1066
|
+
|
|
1067
|
+
let(:from_db) do
|
|
1068
|
+
Person.without(:title).first
|
|
1069
|
+
end
|
|
1070
|
+
|
|
1071
|
+
it "raises an error" do
|
|
1072
|
+
expect {
|
|
1073
|
+
from_db.read_attribute(:title)
|
|
1074
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
|
1075
|
+
end
|
|
1076
|
+
end
|
|
1077
|
+
|
|
1078
|
+
context "when excluding with without and the field was not excluded" do
|
|
1079
|
+
|
|
1080
|
+
let(:from_db) do
|
|
1081
|
+
Person.without(:title).first
|
|
1082
|
+
end
|
|
1083
|
+
|
|
1084
|
+
it "returns nil" do
|
|
1085
|
+
from_db.read_attribute(:undefined_field).should be nil
|
|
1086
|
+
end
|
|
1087
|
+
end
|
|
1088
|
+
end
|
|
857
1089
|
end
|
|
858
1090
|
|
|
859
1091
|
describe "#attribute_present?" do
|
|
@@ -1310,10 +1542,16 @@ describe Mongoid::Attributes do
|
|
|
1310
1542
|
context "when attribute is a Hash" do
|
|
1311
1543
|
let(:person) { Person.new map: { somekey: "somevalue" } }
|
|
1312
1544
|
|
|
1313
|
-
it "raises an error when
|
|
1314
|
-
expect
|
|
1545
|
+
it "raises an error when trying to set a value of invalid type - array" do
|
|
1546
|
+
expect do
|
|
1315
1547
|
person.map = []
|
|
1316
|
-
|
|
1548
|
+
end.to raise_error(Mongoid::Errors::InvalidValue, /Value of type Array cannot be written to a field of type Hash/)
|
|
1549
|
+
end
|
|
1550
|
+
|
|
1551
|
+
it "raises an error when trying to set a value of invalid type - boolean" do
|
|
1552
|
+
expect do
|
|
1553
|
+
person.map = false
|
|
1554
|
+
end.to raise_error(Mongoid::Errors::InvalidValue, /Value of type FalseClass cannot be written to a field of type Hash/)
|
|
1317
1555
|
end
|
|
1318
1556
|
|
|
1319
1557
|
it "can set a Hash value" do
|
|
@@ -1328,10 +1566,16 @@ describe Mongoid::Attributes do
|
|
|
1328
1566
|
expect(person.aliases).to eq([ :alias_1 ])
|
|
1329
1567
|
end
|
|
1330
1568
|
|
|
1331
|
-
it "raises an error when
|
|
1332
|
-
expect
|
|
1569
|
+
it "raises an error when trying to set a value of invalid type - hash" do
|
|
1570
|
+
expect do
|
|
1333
1571
|
person.aliases = {}
|
|
1334
|
-
|
|
1572
|
+
end.to raise_error(Mongoid::Errors::InvalidValue, /Value of type Hash cannot be written to a field of type Array/)
|
|
1573
|
+
end
|
|
1574
|
+
|
|
1575
|
+
it "raises an error when trying to set a value of invalid type - boolean" do
|
|
1576
|
+
expect do
|
|
1577
|
+
person.aliases = false
|
|
1578
|
+
end.to raise_error(Mongoid::Errors::InvalidValue, /Value of type FalseClass cannot be written to a field of type Array/)
|
|
1335
1579
|
end
|
|
1336
1580
|
end
|
|
1337
1581
|
|
|
@@ -1347,6 +1591,51 @@ describe Mongoid::Attributes do
|
|
|
1347
1591
|
expect(dictionary.description).to eq('foo')
|
|
1348
1592
|
end
|
|
1349
1593
|
end
|
|
1594
|
+
|
|
1595
|
+
context 'when writing fields on a document with projection' do
|
|
1596
|
+
|
|
1597
|
+
let!(:person) do
|
|
1598
|
+
Person.create(title: "sir")
|
|
1599
|
+
end
|
|
1600
|
+
|
|
1601
|
+
context "when excluding with only and the field was not excluded" do
|
|
1602
|
+
|
|
1603
|
+
let(:from_db) do
|
|
1604
|
+
Person.only(:_id).first
|
|
1605
|
+
end
|
|
1606
|
+
|
|
1607
|
+
it "raises an error" do
|
|
1608
|
+
expect {
|
|
1609
|
+
from_db.write_attribute(:undefined_field, 'x')
|
|
1610
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
|
1611
|
+
end
|
|
1612
|
+
end
|
|
1613
|
+
|
|
1614
|
+
context "when excluding with without and the field was excluded" do
|
|
1615
|
+
|
|
1616
|
+
let(:from_db) do
|
|
1617
|
+
Person.without(:title).first
|
|
1618
|
+
end
|
|
1619
|
+
|
|
1620
|
+
it "raises an error" do
|
|
1621
|
+
expect {
|
|
1622
|
+
from_db.write_attribute(:title, 'x')
|
|
1623
|
+
}.to raise_error(ActiveModel::MissingAttributeError)
|
|
1624
|
+
end
|
|
1625
|
+
end
|
|
1626
|
+
|
|
1627
|
+
context "when excluding with without and the field was not excluded" do
|
|
1628
|
+
|
|
1629
|
+
let(:from_db) do
|
|
1630
|
+
Person.without(:title).first
|
|
1631
|
+
end
|
|
1632
|
+
|
|
1633
|
+
it "writes the value" do
|
|
1634
|
+
from_db.write_attribute(:undefined_field, 'x')
|
|
1635
|
+
from_db.read_attribute(:undefined_field).should == 'x'
|
|
1636
|
+
end
|
|
1637
|
+
end
|
|
1638
|
+
end
|
|
1350
1639
|
end
|
|
1351
1640
|
|
|
1352
1641
|
describe "#typed_value_for" do
|
|
@@ -1386,7 +1675,7 @@ describe Mongoid::Attributes do
|
|
|
1386
1675
|
end
|
|
1387
1676
|
|
|
1388
1677
|
describe "#typed_attributes" do
|
|
1389
|
-
|
|
1678
|
+
|
|
1390
1679
|
let(:date_time) do
|
|
1391
1680
|
DateTime.current
|
|
1392
1681
|
end
|
|
@@ -1,35 +1,7 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# encoding: utf-8
|
|
3
|
-
|
|
4
1
|
require "spec_helper"
|
|
5
2
|
|
|
6
3
|
describe Mongoid::Clients::Factory do
|
|
7
4
|
|
|
8
|
-
shared_examples_for 'includes seed address' do
|
|
9
|
-
let(:configured_address) do
|
|
10
|
-
address = SpecConfig.instance.addresses.first
|
|
11
|
-
unless address.include?(':')
|
|
12
|
-
address = "#{address}:27017"
|
|
13
|
-
end
|
|
14
|
-
address
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
let(:expected_addresses) do
|
|
18
|
-
[
|
|
19
|
-
configured_address,
|
|
20
|
-
configured_address.sub(/\Alocalhost:/, '127.0.0.1:'),
|
|
21
|
-
configured_address.sub(/\A127\.0\.0\.1:/, 'localhost:'),
|
|
22
|
-
].uniq
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'includes seed address' do
|
|
26
|
-
ok = cluster_addresses.any? do |address|
|
|
27
|
-
expected_addresses.include?(address)
|
|
28
|
-
end
|
|
29
|
-
expect(ok).to be true
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
5
|
describe ".create" do
|
|
34
6
|
|
|
35
7
|
context "when provided a name" do
|
|
@@ -65,12 +37,10 @@ describe Mongoid::Clients::Factory do
|
|
|
65
37
|
expect(client).to be_a(Mongo::Client)
|
|
66
38
|
end
|
|
67
39
|
|
|
68
|
-
|
|
69
|
-
cluster.addresses.
|
|
40
|
+
it "sets the cluster's seeds" do
|
|
41
|
+
expect(cluster.addresses.first.to_s).to eq(SpecConfig.instance.addresses.first)
|
|
70
42
|
end
|
|
71
43
|
|
|
72
|
-
it_behaves_like 'includes seed address'
|
|
73
|
-
|
|
74
44
|
it "sets the platform to Mongoid's platform constant" do
|
|
75
45
|
expect(client.options[:platform]).to eq(Mongoid::PLATFORM_DETAILS)
|
|
76
46
|
end
|
|
@@ -231,14 +201,18 @@ describe Mongoid::Clients::Factory do
|
|
|
231
201
|
end
|
|
232
202
|
|
|
233
203
|
let(:cluster_addresses) do
|
|
234
|
-
cluster.addresses.map
|
|
204
|
+
cluster.addresses.map{ |address| address.to_s }
|
|
235
205
|
end
|
|
236
206
|
|
|
237
207
|
it "returns the default client" do
|
|
238
208
|
expect(client).to be_a(Mongo::Client)
|
|
239
209
|
end
|
|
240
210
|
|
|
241
|
-
|
|
211
|
+
it "sets the cluster's addresses" do
|
|
212
|
+
SpecConfig.instance.addresses.each do |address|
|
|
213
|
+
expect(cluster_addresses).to include(address)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
242
216
|
end
|
|
243
217
|
|
|
244
218
|
context "when nil is provided and no default config" do
|
|
@@ -278,14 +252,18 @@ describe Mongoid::Clients::Factory do
|
|
|
278
252
|
end
|
|
279
253
|
|
|
280
254
|
let(:cluster_addresses) do
|
|
281
|
-
cluster.addresses.map
|
|
255
|
+
cluster.addresses.map{ |address| address.to_s }
|
|
282
256
|
end
|
|
283
257
|
|
|
284
258
|
it "returns the default client" do
|
|
285
259
|
expect(client).to be_a(Mongo::Client)
|
|
286
260
|
end
|
|
287
261
|
|
|
288
|
-
|
|
262
|
+
it "sets the cluster's addresses" do
|
|
263
|
+
SpecConfig.instance.addresses.each do |address|
|
|
264
|
+
expect(cluster_addresses).to include(address)
|
|
265
|
+
end
|
|
266
|
+
end
|
|
289
267
|
end
|
|
290
268
|
|
|
291
269
|
context "when options are provided with string keys" do
|
|
@@ -320,14 +298,18 @@ describe Mongoid::Clients::Factory do
|
|
|
320
298
|
end
|
|
321
299
|
|
|
322
300
|
let(:cluster_addresses) do
|
|
323
|
-
cluster.addresses.map
|
|
301
|
+
cluster.addresses.map{ |address| address.to_s }
|
|
324
302
|
end
|
|
325
303
|
|
|
326
304
|
it "returns the default client" do
|
|
327
305
|
expect(client).to be_a(Mongo::Client)
|
|
328
306
|
end
|
|
329
307
|
|
|
330
|
-
|
|
308
|
+
it "sets the cluster's addresses" do
|
|
309
|
+
SpecConfig.instance.addresses.each do |address|
|
|
310
|
+
expect(cluster_addresses).to include(address)
|
|
311
|
+
end
|
|
312
|
+
end
|
|
331
313
|
|
|
332
314
|
it "sets the server selection timeout" do
|
|
333
315
|
expect(cluster.options[:server_selection_timeout]).to eq(10)
|