mongoid 3.1.7 → 4.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +317 -11
- data/README.md +4 -5
- data/lib/config/locales/en.yml +9 -12
- data/lib/mongoid.rb +6 -75
- data/lib/mongoid/atomic.rb +0 -11
- data/lib/mongoid/atomic/paths/embedded.rb +0 -30
- data/lib/mongoid/atomic/paths/root.rb +0 -13
- data/lib/mongoid/attributes.rb +30 -108
- data/lib/mongoid/attributes/dynamic.rb +154 -0
- data/lib/mongoid/attributes/nested.rb +82 -0
- data/lib/mongoid/attributes/processing.rb +13 -66
- data/lib/mongoid/{dirty.rb → changeable.rb} +5 -2
- data/lib/mongoid/composable.rb +104 -0
- data/lib/mongoid/config.rb +3 -9
- data/lib/mongoid/config/options.rb +1 -1
- data/lib/mongoid/contextual/aggregable/mongo.rb +5 -9
- data/lib/mongoid/contextual/atomic.rb +53 -53
- data/lib/mongoid/contextual/command.rb +26 -0
- data/lib/mongoid/contextual/map_reduce.rb +1 -1
- data/lib/mongoid/contextual/memory.rb +6 -5
- data/lib/mongoid/contextual/mongo.rb +59 -28
- data/lib/mongoid/contextual/text_search.rb +180 -0
- data/lib/mongoid/copyable.rb +2 -3
- data/lib/mongoid/criteria.rb +13 -33
- data/lib/mongoid/criteria/{#findable.rb# → findable.rb} +0 -2
- data/lib/mongoid/{criterion/inspection.rb → criteria/inspectable.rb} +2 -2
- data/lib/mongoid/{criterion → criteria}/marshalable.rb +3 -1
- data/lib/mongoid/{criterion → criteria}/modifiable.rb +1 -1
- data/lib/mongoid/{criterion/scoping.rb → criteria/scopable.rb} +2 -2
- data/lib/mongoid/document.rb +28 -12
- data/lib/mongoid/errors.rb +1 -1
- data/lib/mongoid/errors/document_not_found.rb +2 -1
- data/lib/mongoid/errors/invalid_value.rb +16 -0
- data/lib/mongoid/errors/mongoid_error.rb +1 -1
- data/lib/mongoid/extensions.rb +2 -7
- data/lib/mongoid/extensions/array.rb +2 -2
- data/lib/mongoid/extensions/boolean.rb +14 -17
- data/lib/mongoid/extensions/float.rb +1 -0
- data/lib/mongoid/extensions/hash.rb +1 -1
- data/lib/mongoid/extensions/object.rb +4 -4
- data/lib/mongoid/extensions/object_id.rb +5 -5
- data/lib/mongoid/extensions/range.rb +8 -2
- data/lib/mongoid/extensions/string.rb +5 -17
- data/lib/mongoid/extensions/time.rb +2 -2
- data/lib/mongoid/factory.rb +3 -3
- data/lib/mongoid/fields.rb +9 -8
- data/lib/mongoid/fields/foreign_key.rb +3 -3
- data/lib/mongoid/fields/standard.rb +4 -16
- data/lib/mongoid/fields/validators/macro.rb +11 -3
- data/lib/mongoid/{finders.rb → findable.rb} +6 -2
- data/lib/mongoid/{indexes.rb → indexable.rb} +50 -55
- data/lib/mongoid/indexable/specification.rb +104 -0
- data/lib/mongoid/{indexes → indexable}/validators/options.rb +2 -1
- data/lib/mongoid/{inspection.rb → inspectable.rb} +15 -11
- data/lib/mongoid/{callbacks.rb → interceptable.rb} +3 -52
- data/lib/mongoid/log_subscriber.rb +22 -0
- data/lib/mongoid/matchable.rb +152 -0
- data/lib/mongoid/{matchers → matchable}/all.rb +1 -1
- data/lib/mongoid/{matchers → matchable}/and.rb +2 -2
- data/lib/mongoid/{matchers → matchable}/default.rb +1 -1
- data/lib/mongoid/{matchers → matchable}/exists.rb +1 -1
- data/lib/mongoid/{matchers → matchable}/gt.rb +1 -1
- data/lib/mongoid/{matchers → matchable}/gte.rb +1 -1
- data/lib/mongoid/{matchers → matchable}/in.rb +2 -2
- data/lib/mongoid/{matchers → matchable}/lt.rb +1 -1
- data/lib/mongoid/{matchers → matchable}/lte.rb +1 -1
- data/lib/mongoid/{matchers → matchable}/ne.rb +1 -1
- data/lib/mongoid/{matchers → matchable}/nin.rb +3 -2
- data/lib/mongoid/{matchers → matchable}/or.rb +2 -2
- data/lib/mongoid/{matchers → matchable}/size.rb +1 -1
- data/lib/mongoid/persistable.rb +212 -0
- data/lib/mongoid/persistable/creatable.rb +188 -0
- data/lib/mongoid/persistable/deletable.rb +148 -0
- data/lib/mongoid/persistable/destroyable.rb +55 -0
- data/lib/mongoid/persistable/incrementable.rb +36 -0
- data/lib/mongoid/persistable/logical.rb +38 -0
- data/lib/mongoid/persistable/poppable.rb +39 -0
- data/lib/mongoid/persistable/pullable.rb +55 -0
- data/lib/mongoid/persistable/pushable.rb +62 -0
- data/lib/mongoid/persistable/renamable.rb +35 -0
- data/lib/mongoid/persistable/savable.rb +52 -0
- data/lib/mongoid/persistable/settable.rb +33 -0
- data/lib/mongoid/persistable/unsettable.rb +36 -0
- data/lib/mongoid/persistable/updatable.rb +151 -0
- data/lib/mongoid/persistable/upsertable.rb +55 -0
- data/lib/mongoid/positional.rb +71 -0
- data/lib/mongoid/railtie.rb +32 -45
- data/lib/mongoid/railties/database.rake +12 -6
- data/lib/mongoid/relations.rb +3 -3
- data/lib/mongoid/relations/accessors.rb +13 -46
- data/lib/mongoid/relations/auto_save.rb +15 -36
- data/lib/mongoid/relations/binding.rb +0 -23
- data/lib/mongoid/relations/bindings/embedded/many.rb +1 -3
- data/lib/mongoid/relations/bindings/referenced/in.rb +3 -8
- data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +3 -1
- data/lib/mongoid/relations/builder.rb +1 -1
- data/lib/mongoid/relations/builders.rb +2 -2
- data/lib/mongoid/relations/builders/nested_attributes/many.rb +10 -13
- data/lib/mongoid/relations/builders/nested_attributes/one.rb +4 -5
- data/lib/mongoid/relations/builders/referenced/in.rb +1 -1
- data/lib/mongoid/relations/builders/referenced/many.rb +1 -2
- data/lib/mongoid/relations/builders/referenced/many_to_many.rb +1 -2
- data/lib/mongoid/relations/builders/referenced/one.rb +1 -1
- data/lib/mongoid/relations/cascading.rb +3 -5
- data/lib/mongoid/relations/constraint.rb +1 -1
- data/lib/mongoid/relations/conversions.rb +1 -1
- data/lib/mongoid/relations/counter_cache.rb +39 -15
- data/lib/mongoid/relations/eager.rb +47 -0
- data/lib/mongoid/relations/eager/base.rb +57 -0
- data/lib/mongoid/relations/eager/belongs_to.rb +30 -0
- data/lib/mongoid/relations/eager/has_and_belongs_to_many.rb +40 -0
- data/lib/mongoid/relations/eager/has_many.rb +37 -0
- data/lib/mongoid/relations/eager/has_one.rb +29 -0
- data/lib/mongoid/relations/embedded/batchable.rb +3 -4
- data/lib/mongoid/relations/embedded/many.rb +7 -27
- data/lib/mongoid/relations/macros.rb +2 -4
- data/lib/mongoid/relations/many.rb +30 -31
- data/lib/mongoid/relations/metadata.rb +6 -75
- data/lib/mongoid/relations/nested_builder.rb +2 -2
- data/lib/mongoid/relations/options.rb +1 -0
- data/lib/mongoid/relations/polymorphic.rb +0 -1
- data/lib/mongoid/relations/proxy.rb +10 -32
- data/lib/mongoid/relations/referenced/in.rb +2 -18
- data/lib/mongoid/relations/referenced/many.rb +9 -22
- data/lib/mongoid/relations/referenced/many_to_many.rb +10 -33
- data/lib/mongoid/relations/referenced/one.rb +2 -21
- data/lib/mongoid/relations/synchronization.rb +3 -3
- data/lib/mongoid/relations/touchable.rb +33 -0
- data/lib/mongoid/{reloading.rb → reloadable.rb} +6 -4
- data/lib/mongoid/{scoping.rb → scopable.rb} +26 -3
- data/lib/mongoid/selectable.rb +59 -0
- data/lib/mongoid/{serialization.rb → serializable.rb} +10 -1
- data/lib/mongoid/sessions.rb +37 -345
- data/lib/mongoid/sessions/factory.rb +2 -0
- data/lib/mongoid/sessions/options.rb +176 -0
- data/lib/mongoid/sessions/storage_options.rb +140 -0
- data/lib/mongoid/sessions/thread_options.rb +19 -0
- data/lib/mongoid/sessions/validators/storage.rb +15 -1
- data/lib/mongoid/{sharding.rb → shardable.rb} +5 -1
- data/lib/mongoid/support/query_counter.rb +23 -0
- data/lib/mongoid/threaded.rb +0 -110
- data/lib/mongoid/threaded/lifecycle.rb +0 -28
- data/lib/mongoid/timestamps/updated/short.rb +2 -2
- data/lib/mongoid/{hierarchy.rb → traversable.rb} +9 -5
- data/lib/mongoid/{validations.rb → validatable.rb} +23 -9
- data/lib/mongoid/{validations → validatable}/associated.rb +3 -1
- data/lib/mongoid/{validations → validatable}/format.rb +1 -1
- data/lib/mongoid/{validations → validatable}/length.rb +1 -1
- data/lib/mongoid/{validations → validatable}/localizable.rb +1 -1
- data/lib/mongoid/{validations → validatable}/macros.rb +4 -3
- data/lib/mongoid/{validations → validatable}/presence.rb +1 -1
- data/lib/mongoid/{validations → validatable}/queryable.rb +1 -2
- data/lib/mongoid/{validations → validatable}/uniqueness.rb +3 -3
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +9 -13
- data/lib/rails/generators/mongoid/model/model_generator.rb +0 -1
- data/lib/rails/generators/mongoid/model/templates/model.rb.tt +0 -3
- data/lib/rails/generators/mongoid_generator.rb +3 -40
- data/lib/rails/mongoid.rb +59 -57
- data/lib/support/ruby_version.rb +1 -1
- data/spec/app/models/account.rb +2 -6
- data/spec/app/models/acolyte.rb +1 -0
- data/spec/app/models/actor.rb +0 -1
- data/spec/app/models/address.rb +6 -1
- data/spec/app/models/animal.rb +1 -1
- data/spec/app/models/appointment.rb +2 -2
- data/spec/app/models/article.rb +1 -4
- data/spec/app/models/audio.rb +5 -0
- data/spec/app/models/author.rb +0 -2
- data/spec/app/models/band.rb +3 -2
- data/spec/app/models/bar.rb +1 -0
- data/spec/app/models/book.rb +1 -0
- data/spec/app/models/building.rb +0 -2
- data/spec/app/models/building_address.rb +0 -2
- data/spec/app/models/bus.rb +1 -1
- data/spec/app/models/canvas.rb +1 -1
- data/spec/app/models/contractor.rb +0 -2
- data/spec/app/models/country_code.rb +1 -1
- data/spec/app/models/definition.rb +2 -2
- data/spec/app/models/dragon.rb +4 -0
- data/spec/app/models/drug.rb +1 -3
- data/spec/app/models/dungeon.rb +4 -0
- data/spec/app/models/filesystem.rb +1 -0
- data/spec/app/models/fish.rb +0 -1
- data/spec/app/models/fruits.rb +6 -0
- data/spec/app/models/game.rb +0 -2
- data/spec/app/models/house.rb +0 -2
- data/spec/app/models/item.rb +1 -5
- data/spec/app/models/jar.rb +1 -1
- data/spec/app/models/label.rb +4 -4
- data/spec/app/models/login.rb +1 -1
- data/spec/app/models/movie.rb +1 -0
- data/spec/app/models/name.rb +3 -3
- data/spec/app/models/note.rb +1 -1
- data/spec/app/models/oscar.rb +1 -1
- data/spec/app/models/parent_doc.rb +1 -1
- data/spec/app/models/person.rb +13 -8
- data/spec/app/models/phone.rb +1 -3
- data/spec/app/models/player.rb +1 -1
- data/spec/app/models/post.rb +2 -1
- data/spec/app/models/quiz.rb +0 -3
- data/spec/app/models/record.rb +5 -5
- data/spec/app/models/registry.rb +1 -1
- data/spec/app/models/server.rb +1 -1
- data/spec/app/models/service.rb +3 -3
- data/spec/app/models/sound.rb +5 -0
- data/spec/app/models/template.rb +1 -1
- data/spec/app/models/title.rb +0 -1
- data/spec/app/models/track.rb +5 -5
- data/spec/app/models/tree.rb +1 -1
- data/spec/app/models/video.rb +0 -4
- data/spec/app/models/wiki_page.rb +1 -4
- data/spec/app/models/word.rb +3 -0
- data/spec/app/models/word_origin.rb +1 -1
- data/spec/config/mongoid.yml +7 -8
- data/spec/helpers.rb +18 -0
- data/spec/mongoid/atomic/modifiers_spec.rb +22 -22
- data/spec/mongoid/atomic/paths/embedded/many_spec.rb +8 -49
- data/spec/mongoid/atomic/paths/embedded/one_spec.rb +7 -49
- data/spec/mongoid/atomic/paths/root_spec.rb +3 -61
- data/spec/mongoid/atomic/paths_spec.rb +19 -19
- data/spec/mongoid/atomic_spec.rb +19 -19
- data/spec/mongoid/{nested_attributes_spec.rb → attributes/nested_spec.rb} +335 -448
- data/spec/mongoid/attributes/readonly_spec.rb +16 -16
- data/spec/mongoid/attributes_spec.rb +188 -434
- data/spec/mongoid/{dirty_spec.rb → changeable_spec.rb} +117 -148
- data/spec/mongoid/{components_spec.rb → composable_spec.rb} +3 -3
- data/spec/mongoid/config/environment_spec.rb +3 -3
- data/spec/mongoid/config/options_spec.rb +6 -6
- data/spec/mongoid/config_spec.rb +24 -48
- data/spec/mongoid/contextual/aggregable/memory_spec.rb +12 -12
- data/spec/mongoid/contextual/aggregable/mongo_spec.rb +46 -38
- data/spec/mongoid/contextual/atomic_spec.rb +60 -56
- data/spec/mongoid/contextual/find_and_modify_spec.rb +14 -14
- data/spec/mongoid/contextual/geo_near_spec.rb +22 -22
- data/spec/mongoid/contextual/map_reduce_spec.rb +27 -27
- data/spec/mongoid/contextual/memory_spec.rb +94 -94
- data/spec/mongoid/contextual/mongo_spec.rb +225 -139
- data/spec/mongoid/contextual/text_search_spec.rb +207 -0
- data/spec/mongoid/copyable_spec.rb +56 -68
- data/spec/mongoid/criteria/findable_spec.rb +991 -0
- data/spec/mongoid/{criterion/inspection_spec.rb → criteria/inspectable_spec.rb} +5 -5
- data/spec/mongoid/{criterion → criteria}/marshalable_spec.rb +2 -2
- data/spec/mongoid/criteria/modifiable_spec.rb +1063 -0
- data/spec/mongoid/{criterion/scoping_spec.rb → criteria/scopable_spec.rb} +31 -31
- data/spec/mongoid/criteria_spec.rb +530 -2207
- data/spec/mongoid/document_spec.rb +166 -120
- data/spec/mongoid/equality_spec.rb +22 -22
- data/spec/mongoid/errors/ambiguous_relationship_spec.rb +3 -3
- data/spec/mongoid/errors/callback_spec.rb +3 -3
- data/spec/mongoid/errors/delete_restriction_spec.rb +3 -3
- data/spec/mongoid/errors/document_not_found_spec.rb +11 -11
- data/spec/mongoid/errors/eager_load_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_collection_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_config_option_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_field_option_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_field_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_find_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_includes_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_index_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_options_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_path_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_scope_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_set_polymorphic_relation_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_storage_options_spec.rb +3 -3
- data/spec/mongoid/errors/invalid_time_spec.rb +3 -3
- data/spec/mongoid/errors/inverse_not_found_spec.rb +3 -3
- data/spec/mongoid/errors/mixed_relations_spec.rb +3 -3
- data/spec/mongoid/errors/mixed_session_configuration_spec.rb +3 -3
- data/spec/mongoid/errors/mongoid_error_spec.rb +7 -7
- data/spec/mongoid/errors/nested_attributes_metadata_not_found_spec.rb +3 -3
- data/spec/mongoid/errors/no_environment_spec.rb +3 -3
- data/spec/mongoid/errors/no_map_reduce_output_spec.rb +3 -3
- data/spec/mongoid/errors/no_metadata_spec.rb +3 -3
- data/spec/mongoid/errors/no_parent_spec.rb +3 -3
- data/spec/mongoid/errors/no_session_config_spec.rb +3 -3
- data/spec/mongoid/errors/no_session_database_spec.rb +3 -3
- data/spec/mongoid/errors/no_session_hosts_spec.rb +3 -3
- data/spec/mongoid/errors/no_sessions_config_spec.rb +3 -3
- data/spec/mongoid/errors/readonly_attribute_spec.rb +3 -3
- data/spec/mongoid/errors/scope_overwrite_spec.rb +3 -3
- data/spec/mongoid/errors/too_many_nested_attribute_records_spec.rb +3 -3
- data/spec/mongoid/errors/unknown_attribute_spec.rb +5 -5
- data/spec/mongoid/errors/unsaved_document_spec.rb +3 -3
- data/spec/mongoid/errors/unsupported_javascript_spec.rb +3 -3
- data/spec/mongoid/errors/validations_spec.rb +7 -7
- data/spec/mongoid/extensions/array_spec.rb +61 -61
- data/spec/mongoid/extensions/big_decimal_spec.rb +11 -11
- data/spec/mongoid/extensions/binary_spec.rb +12 -12
- data/spec/mongoid/extensions/boolean_spec.rb +18 -18
- data/spec/mongoid/extensions/date_spec.rb +13 -13
- data/spec/mongoid/extensions/date_time_spec.rb +9 -9
- data/spec/mongoid/extensions/false_class_spec.rb +5 -5
- data/spec/mongoid/extensions/float_spec.rb +29 -15
- data/spec/mongoid/extensions/hash_spec.rb +29 -29
- data/spec/mongoid/extensions/integer_spec.rb +15 -15
- data/spec/mongoid/extensions/module_spec.rb +2 -2
- data/spec/mongoid/extensions/nil_class_spec.rb +1 -1
- data/spec/mongoid/extensions/object_id_spec.rb +134 -134
- data/spec/mongoid/extensions/object_spec.rb +26 -26
- data/spec/mongoid/extensions/range_spec.rb +61 -12
- data/spec/mongoid/extensions/regexp_spec.rb +4 -4
- data/spec/mongoid/extensions/set_spec.rb +4 -4
- data/spec/mongoid/extensions/string_spec.rb +35 -46
- data/spec/mongoid/extensions/symbol_spec.rb +9 -9
- data/spec/mongoid/extensions/time_spec.rb +49 -49
- data/spec/mongoid/extensions/time_with_zone_spec.rb +34 -34
- data/spec/mongoid/extensions/true_class_spec.rb +5 -5
- data/spec/mongoid/extensions_spec.rb +15 -0
- data/spec/mongoid/factory_spec.rb +15 -15
- data/spec/mongoid/fields/foreign_key_spec.rb +73 -66
- data/spec/mongoid/fields/internal/foreign_keys/array_spec.rb +15 -15
- data/spec/mongoid/fields/internal/foreign_keys/object_spec.rb +22 -22
- data/spec/mongoid/fields/localized_spec.rb +23 -23
- data/spec/mongoid/fields/standard_spec.rb +12 -12
- data/spec/mongoid/fields_spec.rb +168 -209
- data/spec/mongoid/{finders_spec.rb → findable_spec.rb} +62 -27
- data/spec/mongoid/indexable/specification_spec.rb +102 -0
- data/spec/mongoid/{indexes_spec.rb → indexable_spec.rb} +171 -51
- data/spec/mongoid/{inspection_spec.rb → inspectable_spec.rb} +6 -14
- data/spec/mongoid/{callbacks_spec.rb → interceptable_spec.rb} +105 -105
- data/spec/mongoid/log_subscriber_spec.rb +74 -0
- data/spec/mongoid/loggable_spec.rb +1 -1
- data/spec/mongoid/{matchers → matchable}/all_spec.rb +4 -4
- data/spec/mongoid/{matchers → matchable}/and_spec.rb +11 -11
- data/spec/mongoid/{matchers → matchable}/default_spec.rb +15 -15
- data/spec/mongoid/{matchers → matchable}/exists_spec.rb +5 -5
- data/spec/mongoid/{matchers → matchable}/gt_spec.rb +9 -8
- data/spec/mongoid/{matchers → matchable}/gte_spec.rb +7 -7
- data/spec/mongoid/matchable/in_spec.rb +49 -0
- data/spec/mongoid/{matchers → matchable}/lt_spec.rb +7 -7
- data/spec/mongoid/{matchers → matchable}/lte_spec.rb +7 -7
- data/spec/mongoid/{matchers → matchable}/ne_spec.rb +3 -3
- data/spec/mongoid/matchable/nin_spec.rb +48 -0
- data/spec/mongoid/{matchers → matchable}/or_spec.rb +6 -6
- data/spec/mongoid/{matchers → matchable}/size_spec.rb +3 -3
- data/spec/mongoid/{matchers_spec.rb → matchable_spec.rb} +41 -41
- data/spec/mongoid/persistable/creatable_spec.rb +512 -0
- data/spec/mongoid/persistable/deletable_spec.rb +205 -0
- data/spec/mongoid/persistable/destroyable_spec.rb +148 -0
- data/spec/mongoid/persistable/incrementable_spec.rb +173 -0
- data/spec/mongoid/persistable/logical_spec.rb +143 -0
- data/spec/mongoid/persistable/poppable_spec.rb +115 -0
- data/spec/mongoid/persistable/pullable_spec.rb +228 -0
- data/spec/mongoid/persistable/pushable_spec.rb +258 -0
- data/spec/mongoid/persistable/renamable_spec.rb +135 -0
- data/spec/mongoid/persistable/savable_spec.rb +432 -0
- data/spec/mongoid/persistable/settable_spec.rb +139 -0
- data/spec/mongoid/persistable/unsettable_spec.rb +155 -0
- data/spec/mongoid/persistable/updatable_spec.rb +558 -0
- data/spec/mongoid/persistable/upsertable_spec.rb +106 -0
- data/spec/mongoid/persistable_spec.rb +206 -0
- data/spec/mongoid/{atomic/positionable_spec.rb → positional_spec.rb} +19 -14
- data/spec/mongoid/railties/document_spec.rb +2 -2
- data/spec/mongoid/relations/accessors_spec.rb +53 -145
- data/spec/mongoid/relations/auto_save_spec.rb +36 -16
- data/spec/mongoid/relations/bindings/embedded/in_spec.rb +6 -6
- data/spec/mongoid/relations/bindings/embedded/many_spec.rb +2 -2
- data/spec/mongoid/relations/bindings/embedded/one_spec.rb +3 -3
- data/spec/mongoid/relations/bindings/referenced/in_spec.rb +12 -12
- data/spec/mongoid/relations/bindings/referenced/many_spec.rb +6 -6
- data/spec/mongoid/relations/bindings/referenced/many_to_many_spec.rb +9 -9
- data/spec/mongoid/relations/bindings/referenced/one_spec.rb +6 -6
- data/spec/mongoid/relations/builders/embedded/in_spec.rb +4 -4
- data/spec/mongoid/relations/builders/embedded/many_spec.rb +18 -18
- data/spec/mongoid/relations/builders/embedded/one_spec.rb +11 -11
- data/spec/mongoid/relations/builders/nested_attributes/many_spec.rb +12 -13
- data/spec/mongoid/relations/builders/nested_attributes/one_spec.rb +14 -14
- data/spec/mongoid/relations/builders/referenced/in_spec.rb +22 -33
- data/spec/mongoid/relations/builders/referenced/many_spec.rb +15 -15
- data/spec/mongoid/relations/builders/referenced/many_to_many_spec.rb +18 -18
- data/spec/mongoid/relations/builders/referenced/one_spec.rb +11 -24
- data/spec/mongoid/relations/builders_spec.rb +21 -21
- data/spec/mongoid/relations/cascading/delete_spec.rb +7 -7
- data/spec/mongoid/relations/cascading/destroy_spec.rb +2 -2
- data/spec/mongoid/relations/cascading/nullify_spec.rb +2 -2
- data/spec/mongoid/relations/cascading/restrict_spec.rb +3 -3
- data/spec/mongoid/relations/cascading_spec.rb +16 -16
- data/spec/mongoid/relations/constraint_spec.rb +8 -7
- data/spec/mongoid/relations/conversions_spec.rb +16 -14
- data/spec/mongoid/relations/counter_cache_spec.rb +85 -0
- data/spec/mongoid/relations/cyclic_spec.rb +18 -18
- data/spec/mongoid/relations/eager/belongs_to_spec.rb +154 -0
- data/spec/mongoid/relations/eager/has_and_belongs_to_many_spec.rb +143 -0
- data/spec/mongoid/relations/eager/has_many_spec.rb +207 -0
- data/spec/mongoid/relations/eager/has_one_spec.rb +163 -0
- data/spec/mongoid/relations/eager_spec.rb +228 -0
- data/spec/mongoid/relations/embedded/dirty_spec.rb +8 -8
- data/spec/mongoid/relations/embedded/in_spec.rb +55 -56
- data/spec/mongoid/relations/embedded/many_spec.rb +357 -367
- data/spec/mongoid/relations/embedded/one_spec.rb +98 -139
- data/spec/mongoid/relations/macros_spec.rb +108 -102
- data/spec/mongoid/relations/metadata_spec.rb +147 -241
- data/spec/mongoid/relations/options_spec.rb +1 -1
- data/spec/mongoid/relations/polymorphic_spec.rb +13 -17
- data/spec/mongoid/relations/proxy_spec.rb +2 -2
- data/spec/mongoid/relations/referenced/in_spec.rb +128 -303
- data/spec/mongoid/relations/referenced/many_spec.rb +379 -522
- data/spec/mongoid/relations/referenced/many_to_many_spec.rb +345 -417
- data/spec/mongoid/relations/referenced/one_spec.rb +148 -263
- data/spec/mongoid/relations/reflections_spec.rb +6 -6
- data/spec/mongoid/relations/synchronization_spec.rb +46 -50
- data/spec/mongoid/relations/targets/enumerable_spec.rb +116 -116
- data/spec/mongoid/relations/touchable_spec.rb +296 -0
- data/spec/mongoid/relations_spec.rb +16 -15
- data/spec/mongoid/{reloading_spec.rb → reloadable_spec.rb} +20 -60
- data/spec/mongoid/{scoping_spec.rb → scopable_spec.rb} +74 -126
- data/spec/mongoid/selectable_spec.rb +134 -0
- data/spec/mongoid/{serialization_spec.rb → serializable_spec.rb} +111 -82
- data/spec/mongoid/sessions/factory_spec.rb +49 -28
- data/spec/mongoid/sessions/mongo_uri_spec.rb +7 -7
- data/spec/mongoid/sessions/options_spec.rb +92 -0
- data/spec/mongoid/sessions_spec.rb +288 -177
- data/spec/mongoid/{sharding_spec.rb → shardable_spec.rb} +8 -8
- data/spec/mongoid/state_spec.rb +10 -10
- data/spec/mongoid/threaded_spec.rb +17 -70
- data/spec/mongoid/timestamps/created/short_spec.rb +6 -6
- data/spec/mongoid/timestamps/created_spec.rb +5 -5
- data/spec/mongoid/timestamps/updated/short_spec.rb +10 -10
- data/spec/mongoid/timestamps/updated_spec.rb +8 -12
- data/spec/mongoid/timestamps_spec.rb +7 -11
- data/spec/mongoid/{hierarchy_spec.rb → traversable_spec.rb} +19 -19
- data/spec/mongoid/{validations → validatable}/associated_spec.rb +18 -18
- data/spec/mongoid/{validations → validatable}/format_spec.rb +6 -6
- data/spec/mongoid/{validations → validatable}/length_spec.rb +7 -7
- data/spec/mongoid/{validations → validatable}/numericality_spec.rb +1 -1
- data/spec/mongoid/{validations → validatable}/presence_spec.rb +31 -38
- data/spec/mongoid/{validations → validatable}/uniqueness_spec.rb +126 -183
- data/spec/mongoid/{validations_spec.rb → validatable_spec.rb} +28 -28
- data/spec/mongoid_spec.rb +8 -8
- data/spec/rails/mongoid_spec.rb +72 -87
- data/spec/spec_helper.rb +19 -17
- metadata +261 -283
- data/lib/mongoid/atomic/positionable.rb +0 -73
- data/lib/mongoid/components.rb +0 -92
- data/lib/mongoid/config/inflections.rb +0 -6
- data/lib/mongoid/contextual/eager.rb +0 -158
- data/lib/mongoid/criterion/findable.rb +0 -179
- data/lib/mongoid/errors/versioning_not_on_root.rb +0 -23
- data/lib/mongoid/identity_map.rb +0 -163
- data/lib/mongoid/json.rb +0 -16
- data/lib/mongoid/matchers.rb +0 -32
- data/lib/mongoid/matchers/strategies.rb +0 -97
- data/lib/mongoid/multi_parameter_attributes.rb +0 -105
- data/lib/mongoid/nested_attributes.rb +0 -78
- data/lib/mongoid/observer.rb +0 -192
- data/lib/mongoid/paranoia.rb +0 -136
- data/lib/mongoid/persistence.rb +0 -357
- data/lib/mongoid/persistence/atomic.rb +0 -231
- data/lib/mongoid/persistence/atomic/add_to_set.rb +0 -47
- data/lib/mongoid/persistence/atomic/bit.rb +0 -35
- data/lib/mongoid/persistence/atomic/inc.rb +0 -45
- data/lib/mongoid/persistence/atomic/operation.rb +0 -154
- data/lib/mongoid/persistence/atomic/pop.rb +0 -32
- data/lib/mongoid/persistence/atomic/pull.rb +0 -32
- data/lib/mongoid/persistence/atomic/pull_all.rb +0 -32
- data/lib/mongoid/persistence/atomic/push.rb +0 -25
- data/lib/mongoid/persistence/atomic/push_all.rb +0 -25
- data/lib/mongoid/persistence/atomic/rename.rb +0 -30
- data/lib/mongoid/persistence/atomic/sets.rb +0 -28
- data/lib/mongoid/persistence/atomic/unset.rb +0 -27
- data/lib/mongoid/persistence/deletion.rb +0 -31
- data/lib/mongoid/persistence/insertion.rb +0 -38
- data/lib/mongoid/persistence/modification.rb +0 -35
- data/lib/mongoid/persistence/operations.rb +0 -214
- data/lib/mongoid/persistence/operations/embedded/insert.rb +0 -46
- data/lib/mongoid/persistence/operations/embedded/remove.rb +0 -43
- data/lib/mongoid/persistence/operations/insert.rb +0 -34
- data/lib/mongoid/persistence/operations/remove.rb +0 -33
- data/lib/mongoid/persistence/operations/update.rb +0 -59
- data/lib/mongoid/persistence/operations/upsert.rb +0 -28
- data/lib/mongoid/persistence/upsertion.rb +0 -31
- data/lib/mongoid/unit_of_work.rb +0 -61
- data/lib/mongoid/versioning.rb +0 -217
- data/lib/rack/mongoid.rb +0 -2
- data/lib/rack/mongoid/middleware/identity_map.rb +0 -39
- data/lib/rails/generators/mongoid/observer/observer_generator.rb +0 -17
- data/lib/rails/generators/mongoid/observer/templates/observer.rb.tt +0 -4
- data/spec/app/models/actor_observer.rb +0 -15
- data/spec/app/models/callback_recorder.rb +0 -25
- data/spec/app/models/draft.rb +0 -9
- data/spec/app/models/paranoid_phone.rb +0 -25
- data/spec/app/models/paranoid_post.rb +0 -36
- data/spec/app/models/phone_observer.rb +0 -6
- data/spec/mongoid/#atomic_spec.rb# +0 -365
- data/spec/mongoid/attributes/processing_spec.rb +0 -149
- data/spec/mongoid/criterion/destructive_spec.rb +0 -101
- data/spec/mongoid/criterion/modifiable_spec.rb +0 -409
- data/spec/mongoid/criterion/modification_spec.rb +0 -402
- data/spec/mongoid/errors/versioning_not_on_root_spec.rb +0 -29
- data/spec/mongoid/identity_map_spec.rb +0 -564
- data/spec/mongoid/json_spec.rb +0 -33
- data/spec/mongoid/matchers/in_spec.rb +0 -25
- data/spec/mongoid/matchers/nin_spec.rb +0 -25
- data/spec/mongoid/multi_parameter_attributes_spec.rb +0 -128
- data/spec/mongoid/observer_spec.rb +0 -290
- data/spec/mongoid/paranoia_spec.rb +0 -759
- data/spec/mongoid/persistence/atomic/add_to_set_spec.rb +0 -262
- data/spec/mongoid/persistence/atomic/bit_spec.rb +0 -88
- data/spec/mongoid/persistence/atomic/inc_spec.rb +0 -133
- data/spec/mongoid/persistence/atomic/pop_spec.rb +0 -111
- data/spec/mongoid/persistence/atomic/pull_all_spec.rb +0 -77
- data/spec/mongoid/persistence/atomic/pull_spec.rb +0 -80
- data/spec/mongoid/persistence/atomic/push_all_spec.rb +0 -77
- data/spec/mongoid/persistence/atomic/push_spec.rb +0 -77
- data/spec/mongoid/persistence/atomic/rename_spec.rb +0 -42
- data/spec/mongoid/persistence/atomic/sets_spec.rb +0 -154
- data/spec/mongoid/persistence/atomic/unset_spec.rb +0 -65
- data/spec/mongoid/persistence/atomic_spec.rb +0 -216
- data/spec/mongoid/persistence/operations/embedded/insert_spec.rb +0 -191
- data/spec/mongoid/persistence/operations/embedded/remove_spec.rb +0 -8
- data/spec/mongoid/persistence/operations/insert_spec.rb +0 -149
- data/spec/mongoid/persistence/operations/remove_spec.rb +0 -113
- data/spec/mongoid/persistence/operations/update_spec.rb +0 -141
- data/spec/mongoid/persistence/operations/upsert_spec.rb +0 -59
- data/spec/mongoid/persistence/operations_spec.rb +0 -313
- data/spec/mongoid/persistence_spec.rb +0 -2279
- data/spec/mongoid/unit_of_work_spec.rb +0 -196
- data/spec/mongoid/versioning_spec.rb +0 -540
- data/spec/rack/mongoid/middleware/identity_map_spec.rb +0 -72
@@ -15,7 +15,7 @@ describe Mongoid::Relations::Metadata do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "returns false" do
|
18
|
-
metadata.
|
18
|
+
expect(metadata).to_not be_counter_cached
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -30,7 +30,7 @@ describe Mongoid::Relations::Metadata do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "returns true" do
|
33
|
-
metadata.
|
33
|
+
expect(metadata).to be_counter_cached
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -45,7 +45,7 @@ describe Mongoid::Relations::Metadata do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
it "returns true" do
|
48
|
-
metadata.
|
48
|
+
expect(metadata).to be_counter_cached
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -59,7 +59,7 @@ describe Mongoid::Relations::Metadata do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "returns false" do
|
62
|
-
metadata.
|
62
|
+
expect(metadata).to_not be_counter_cached
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -104,7 +104,7 @@ describe Mongoid::Relations::Metadata do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
it "returns the name given" do
|
107
|
-
metadata.counter_cache_column_name.
|
107
|
+
expect(metadata.counter_cache_column_name).to eq(counter_cache_name)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -121,7 +121,7 @@ describe Mongoid::Relations::Metadata do
|
|
121
121
|
end
|
122
122
|
|
123
123
|
it "returns true" do
|
124
|
-
metadata.
|
124
|
+
expect(metadata).to be_autobuilding
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -135,7 +135,7 @@ describe Mongoid::Relations::Metadata do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it "returns false" do
|
138
|
-
metadata.
|
138
|
+
expect(metadata).to_not be_autobuilding
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -148,7 +148,7 @@ describe Mongoid::Relations::Metadata do
|
|
148
148
|
end
|
149
149
|
|
150
150
|
it "returns false" do
|
151
|
-
metadata.
|
151
|
+
expect(metadata).to_not be_autobuilding
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
@@ -160,16 +160,17 @@ describe Mongoid::Relations::Metadata do
|
|
160
160
|
end
|
161
161
|
|
162
162
|
let(:object) do
|
163
|
-
|
163
|
+
double
|
164
164
|
end
|
165
165
|
|
166
166
|
let(:base) do
|
167
|
-
|
167
|
+
double
|
168
168
|
end
|
169
169
|
|
170
170
|
it "returns the builder from the relation" do
|
171
|
-
|
172
|
-
|
171
|
+
expect(
|
172
|
+
metadata.builder(base, object)
|
173
|
+
).to be_a_kind_of(Mongoid::Relations::Builders::Embedded::One)
|
173
174
|
end
|
174
175
|
end
|
175
176
|
|
@@ -185,7 +186,7 @@ describe Mongoid::Relations::Metadata do
|
|
185
186
|
end
|
186
187
|
|
187
188
|
it "returns true" do
|
188
|
-
metadata.
|
189
|
+
expect(metadata).to be_cascading_callbacks
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
@@ -199,7 +200,7 @@ describe Mongoid::Relations::Metadata do
|
|
199
200
|
end
|
200
201
|
|
201
202
|
it "returns false" do
|
202
|
-
metadata.
|
203
|
+
expect(metadata).to_not be_cascading_callbacks
|
203
204
|
end
|
204
205
|
end
|
205
206
|
|
@@ -212,7 +213,7 @@ describe Mongoid::Relations::Metadata do
|
|
212
213
|
end
|
213
214
|
|
214
215
|
it "returns false" do
|
215
|
-
metadata.
|
216
|
+
expect(metadata).to_not be_cascading_callbacks
|
216
217
|
end
|
217
218
|
end
|
218
219
|
end
|
@@ -229,7 +230,7 @@ describe Mongoid::Relations::Metadata do
|
|
229
230
|
end
|
230
231
|
|
231
232
|
it "returns nil" do
|
232
|
-
metadata.cascade_strategy.
|
233
|
+
expect(metadata.cascade_strategy).to be_nil
|
233
234
|
end
|
234
235
|
end
|
235
236
|
|
@@ -244,7 +245,7 @@ describe Mongoid::Relations::Metadata do
|
|
244
245
|
end
|
245
246
|
|
246
247
|
it "returns the delete strategy" do
|
247
|
-
metadata.cascade_strategy.
|
248
|
+
expect(metadata.cascade_strategy).to eq(
|
248
249
|
Mongoid::Relations::Cascading::Delete
|
249
250
|
)
|
250
251
|
end
|
@@ -261,7 +262,7 @@ describe Mongoid::Relations::Metadata do
|
|
261
262
|
end
|
262
263
|
|
263
264
|
it "returns the destroy strategy" do
|
264
|
-
metadata.cascade_strategy.
|
265
|
+
expect(metadata.cascade_strategy).to eq(
|
265
266
|
Mongoid::Relations::Cascading::Destroy
|
266
267
|
)
|
267
268
|
end
|
@@ -278,7 +279,7 @@ describe Mongoid::Relations::Metadata do
|
|
278
279
|
end
|
279
280
|
|
280
281
|
it "returns the nullify strategy" do
|
281
|
-
metadata.cascade_strategy.
|
282
|
+
expect(metadata.cascade_strategy).to eq(
|
282
283
|
Mongoid::Relations::Cascading::Nullify
|
283
284
|
)
|
284
285
|
end
|
@@ -295,7 +296,7 @@ describe Mongoid::Relations::Metadata do
|
|
295
296
|
end
|
296
297
|
|
297
298
|
it "returns the constraint object" do
|
298
|
-
metadata.constraint.
|
299
|
+
expect(metadata.constraint).to be_a(Mongoid::Relations::Constraint)
|
299
300
|
end
|
300
301
|
end
|
301
302
|
|
@@ -319,7 +320,7 @@ describe Mongoid::Relations::Metadata do
|
|
319
320
|
|
320
321
|
it "concatenates the result from #find_module and name.classify" do
|
321
322
|
metadata.should_receive(:find_module).once.and_return("Fruit")
|
322
|
-
classified.
|
323
|
+
expect(classified).to eq("Fruit::Name")
|
323
324
|
end
|
324
325
|
end
|
325
326
|
|
@@ -348,7 +349,7 @@ describe Mongoid::Relations::Metadata do
|
|
348
349
|
end
|
349
350
|
|
350
351
|
it "returns nil" do
|
351
|
-
mod.
|
352
|
+
expect(mod).to be_nil
|
352
353
|
end
|
353
354
|
end
|
354
355
|
|
@@ -359,7 +360,7 @@ describe Mongoid::Relations::Metadata do
|
|
359
360
|
end
|
360
361
|
|
361
362
|
it "returns nil" do
|
362
|
-
mod.
|
363
|
+
expect(mod).to be_nil
|
363
364
|
end
|
364
365
|
end
|
365
366
|
|
@@ -378,7 +379,7 @@ describe Mongoid::Relations::Metadata do
|
|
378
379
|
end
|
379
380
|
|
380
381
|
it "returns nil" do
|
381
|
-
mod.
|
382
|
+
expect(mod).to be_nil
|
382
383
|
end
|
383
384
|
end
|
384
385
|
|
@@ -389,7 +390,7 @@ describe Mongoid::Relations::Metadata do
|
|
389
390
|
end
|
390
391
|
|
391
392
|
it "returns root namespace" do
|
392
|
-
mod.
|
393
|
+
expect(mod).to be_empty
|
393
394
|
end
|
394
395
|
end
|
395
396
|
|
@@ -406,7 +407,7 @@ describe Mongoid::Relations::Metadata do
|
|
406
407
|
end
|
407
408
|
|
408
409
|
it "returns Fruits" do
|
409
|
-
mod.
|
410
|
+
expect(mod).to eq("Fruits")
|
410
411
|
end
|
411
412
|
end
|
412
413
|
|
@@ -421,7 +422,7 @@ describe Mongoid::Relations::Metadata do
|
|
421
422
|
end
|
422
423
|
|
423
424
|
it "returns Fruits" do
|
424
|
-
mod.
|
425
|
+
expect(mod).to eq("Fruits")
|
425
426
|
end
|
426
427
|
end
|
427
428
|
|
@@ -436,7 +437,7 @@ describe Mongoid::Relations::Metadata do
|
|
436
437
|
end
|
437
438
|
|
438
439
|
it "returns nil" do
|
439
|
-
mod.
|
440
|
+
expect(mod).to be_nil
|
440
441
|
end
|
441
442
|
end
|
442
443
|
end
|
@@ -458,7 +459,7 @@ describe Mongoid::Relations::Metadata do
|
|
458
459
|
end
|
459
460
|
|
460
461
|
it "returns the stripped class name" do
|
461
|
-
metadata.class_name.
|
462
|
+
expect(metadata.class_name).to eq("Person")
|
462
463
|
end
|
463
464
|
end
|
464
465
|
|
@@ -472,7 +473,7 @@ describe Mongoid::Relations::Metadata do
|
|
472
473
|
end
|
473
474
|
|
474
475
|
it "constantizes the class name" do
|
475
|
-
metadata.class_name.
|
476
|
+
expect(metadata.class_name).to eq("Person")
|
476
477
|
end
|
477
478
|
end
|
478
479
|
end
|
@@ -494,7 +495,7 @@ describe Mongoid::Relations::Metadata do
|
|
494
495
|
end
|
495
496
|
|
496
497
|
it "classifies and constantizes the association name and adds the module" do
|
497
|
-
metadata.class_name.
|
498
|
+
expect(metadata.class_name).to eq("Name")
|
498
499
|
end
|
499
500
|
end
|
500
501
|
|
@@ -509,7 +510,7 @@ describe Mongoid::Relations::Metadata do
|
|
509
510
|
end
|
510
511
|
|
511
512
|
it "classifies and constantizes the association name and adds the module" do
|
512
|
-
metadata.class_name.
|
513
|
+
expect(metadata.class_name).to eq("Address")
|
513
514
|
end
|
514
515
|
end
|
515
516
|
|
@@ -528,7 +529,7 @@ describe Mongoid::Relations::Metadata do
|
|
528
529
|
end
|
529
530
|
|
530
531
|
it "classifies and constantizes the association name and adds the module" do
|
531
|
-
metadata.class_name.
|
532
|
+
expect(metadata.class_name).to eq("Fruits::Apple")
|
532
533
|
end
|
533
534
|
end
|
534
535
|
|
@@ -543,7 +544,7 @@ describe Mongoid::Relations::Metadata do
|
|
543
544
|
end
|
544
545
|
|
545
546
|
it "classifies and constantizes the association name and adds the module" do
|
546
|
-
metadata.class_name.
|
547
|
+
expect(metadata.class_name).to eq("Fruits::Apple")
|
547
548
|
end
|
548
549
|
end
|
549
550
|
|
@@ -563,7 +564,7 @@ describe Mongoid::Relations::Metadata do
|
|
563
564
|
end
|
564
565
|
|
565
566
|
it "classifies and constantizes the association name" do
|
566
|
-
metadata.class_name.
|
567
|
+
expect(metadata.class_name).to eq("Name")
|
567
568
|
end
|
568
569
|
end
|
569
570
|
|
@@ -578,7 +579,7 @@ describe Mongoid::Relations::Metadata do
|
|
578
579
|
end
|
579
580
|
|
580
581
|
it "classifies and constantizes the association name" do
|
581
|
-
metadata.class_name.
|
582
|
+
expect(metadata.class_name).to eq("Address")
|
582
583
|
end
|
583
584
|
end
|
584
585
|
end
|
@@ -597,7 +598,7 @@ describe Mongoid::Relations::Metadata do
|
|
597
598
|
end
|
598
599
|
|
599
600
|
it "returns true" do
|
600
|
-
metadata.
|
601
|
+
expect(metadata).to be_destructive
|
601
602
|
end
|
602
603
|
end
|
603
604
|
|
@@ -610,7 +611,7 @@ describe Mongoid::Relations::Metadata do
|
|
610
611
|
end
|
611
612
|
|
612
613
|
it "returns false" do
|
613
|
-
metadata.
|
614
|
+
expect(metadata).to_not be_destructive
|
614
615
|
end
|
615
616
|
end
|
616
617
|
end
|
@@ -626,7 +627,7 @@ describe Mongoid::Relations::Metadata do
|
|
626
627
|
end
|
627
628
|
|
628
629
|
it "returns true" do
|
629
|
-
metadata.
|
630
|
+
expect(metadata).to be_embedded
|
630
631
|
end
|
631
632
|
end
|
632
633
|
|
@@ -639,7 +640,7 @@ describe Mongoid::Relations::Metadata do
|
|
639
640
|
end
|
640
641
|
|
641
642
|
it "returns false" do
|
642
|
-
metadata.
|
643
|
+
expect(metadata).to_not be_embedded
|
643
644
|
end
|
644
645
|
end
|
645
646
|
end
|
@@ -654,7 +655,7 @@ describe Mongoid::Relations::Metadata do
|
|
654
655
|
end
|
655
656
|
|
656
657
|
it "returns the extend property" do
|
657
|
-
metadata.extension.
|
658
|
+
expect(metadata.extension).to eq(:value)
|
658
659
|
end
|
659
660
|
end
|
660
661
|
|
@@ -670,7 +671,7 @@ describe Mongoid::Relations::Metadata do
|
|
670
671
|
end
|
671
672
|
|
672
673
|
it "returns true" do
|
673
|
-
metadata.extension
|
674
|
+
expect(metadata.extension?).to be true
|
674
675
|
end
|
675
676
|
end
|
676
677
|
|
@@ -683,7 +684,7 @@ describe Mongoid::Relations::Metadata do
|
|
683
684
|
end
|
684
685
|
|
685
686
|
it "returns false" do
|
686
|
-
metadata.extension
|
687
|
+
expect(metadata.extension?).to be false
|
687
688
|
end
|
688
689
|
end
|
689
690
|
end
|
@@ -706,7 +707,7 @@ describe Mongoid::Relations::Metadata do
|
|
706
707
|
end
|
707
708
|
|
708
709
|
it "returns the foreign_key" do
|
709
|
-
metadata.foreign_key.
|
710
|
+
expect(metadata.foreign_key).to eq("person_id")
|
710
711
|
end
|
711
712
|
end
|
712
713
|
|
@@ -721,7 +722,7 @@ describe Mongoid::Relations::Metadata do
|
|
721
722
|
end
|
722
723
|
|
723
724
|
it "returns the foreign_key" do
|
724
|
-
metadata.foreign_key.
|
725
|
+
expect(metadata.foreign_key).to eq("person_id")
|
725
726
|
end
|
726
727
|
end
|
727
728
|
|
@@ -736,7 +737,7 @@ describe Mongoid::Relations::Metadata do
|
|
736
737
|
end
|
737
738
|
|
738
739
|
it "returns the foreign_key without the module name" do
|
739
|
-
metadata.foreign_key.
|
740
|
+
expect(metadata.foreign_key).to eq("apple_id")
|
740
741
|
end
|
741
742
|
end
|
742
743
|
end
|
@@ -751,7 +752,7 @@ describe Mongoid::Relations::Metadata do
|
|
751
752
|
end
|
752
753
|
|
753
754
|
it "returns the foreign_key" do
|
754
|
-
metadata.foreign_key.
|
755
|
+
expect(metadata.foreign_key).to eq("person_ids")
|
755
756
|
end
|
756
757
|
|
757
758
|
context "given a specific foreign key" do
|
@@ -765,7 +766,7 @@ describe Mongoid::Relations::Metadata do
|
|
765
766
|
end
|
766
767
|
|
767
768
|
it "returns the foreign_key" do
|
768
|
-
metadata.foreign_key.
|
769
|
+
expect(metadata.foreign_key).to eq("follower_list")
|
769
770
|
end
|
770
771
|
end
|
771
772
|
|
@@ -780,7 +781,7 @@ describe Mongoid::Relations::Metadata do
|
|
780
781
|
end
|
781
782
|
|
782
783
|
it "returns the foreign_key" do
|
783
|
-
metadata.foreign_key.
|
784
|
+
expect(metadata.foreign_key).to eq("follower_ids")
|
784
785
|
end
|
785
786
|
end
|
786
787
|
|
@@ -796,11 +797,11 @@ describe Mongoid::Relations::Metadata do
|
|
796
797
|
end
|
797
798
|
|
798
799
|
it "returns the foreign_key without the module name" do
|
799
|
-
metadata.foreign_key.
|
800
|
+
expect(metadata.foreign_key).to eq("banana_ids")
|
800
801
|
end
|
801
802
|
|
802
803
|
it "returns the inverse_foreign_key without the module name" do
|
803
|
-
metadata.inverse_foreign_key.
|
804
|
+
expect(metadata.inverse_foreign_key).to eq("apple_ids")
|
804
805
|
end
|
805
806
|
end
|
806
807
|
end
|
@@ -819,7 +820,7 @@ describe Mongoid::Relations::Metadata do
|
|
819
820
|
end
|
820
821
|
|
821
822
|
it "returns the inverse foreign key" do
|
822
|
-
metadata.foreign_key.
|
823
|
+
expect(metadata.foreign_key).to eq("person_id")
|
823
824
|
end
|
824
825
|
end
|
825
826
|
|
@@ -837,7 +838,7 @@ describe Mongoid::Relations::Metadata do
|
|
837
838
|
end
|
838
839
|
|
839
840
|
it "returns the inverse_of plus suffix" do
|
840
|
-
metadata.foreign_key.
|
841
|
+
expect(metadata.foreign_key).to eq("creator_id")
|
841
842
|
end
|
842
843
|
end
|
843
844
|
|
@@ -852,23 +853,42 @@ describe Mongoid::Relations::Metadata do
|
|
852
853
|
end
|
853
854
|
|
854
855
|
it "returns the inverse foreign key" do
|
855
|
-
metadata.foreign_key.
|
856
|
+
expect(metadata.foreign_key).to eq("person_id")
|
856
857
|
end
|
857
858
|
end
|
858
859
|
|
859
860
|
context "when the class is namespaced" do
|
860
861
|
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
862
|
+
context "when name doesnt include namespace" do
|
863
|
+
|
864
|
+
let(:metadata) do
|
865
|
+
described_class.new(
|
866
|
+
name: :bananas,
|
867
|
+
relation: Mongoid::Relations::Referenced::Many,
|
868
|
+
inverse_class_name: "Fruits::Apple",
|
869
|
+
class_name: "Fruits::Banana"
|
870
|
+
)
|
871
|
+
end
|
872
|
+
|
873
|
+
it "returns the foreign_key without the module name" do
|
874
|
+
expect(metadata.foreign_key).to eq("apple_id")
|
875
|
+
end
|
868
876
|
end
|
869
877
|
|
870
|
-
|
871
|
-
|
878
|
+
context "when name include namespace" do
|
879
|
+
|
880
|
+
let(:metadata) do
|
881
|
+
described_class.new(
|
882
|
+
name: :fruits_melons,
|
883
|
+
relation: Mongoid::Relations::Referenced::Many,
|
884
|
+
inverse_class_name: "Fruits::Apple",
|
885
|
+
class_name: "Fruits::Melon"
|
886
|
+
)
|
887
|
+
end
|
888
|
+
|
889
|
+
it "returns the foreign_key with the module name" do
|
890
|
+
expect(metadata.foreign_key).to eq("fruit_apple_id")
|
891
|
+
end
|
872
892
|
end
|
873
893
|
end
|
874
894
|
end
|
@@ -882,8 +902,8 @@ describe Mongoid::Relations::Metadata do
|
|
882
902
|
)
|
883
903
|
end
|
884
904
|
|
885
|
-
it "returns
|
886
|
-
metadata.foreign_key.
|
905
|
+
it "returns a nil foreign key" do
|
906
|
+
expect(metadata.foreign_key).to be_nil
|
887
907
|
end
|
888
908
|
end
|
889
909
|
end
|
@@ -900,7 +920,7 @@ describe Mongoid::Relations::Metadata do
|
|
900
920
|
end
|
901
921
|
|
902
922
|
it "returns the foreign_key" do
|
903
|
-
metadata.foreign_key.
|
923
|
+
expect(metadata.foreign_key).to eq("blog_post_id")
|
904
924
|
end
|
905
925
|
end
|
906
926
|
end
|
@@ -918,7 +938,7 @@ describe Mongoid::Relations::Metadata do
|
|
918
938
|
end
|
919
939
|
|
920
940
|
it "returns an empty array" do
|
921
|
-
metadata.foreign_key_default.
|
941
|
+
expect(metadata.foreign_key_default).to be_empty
|
922
942
|
end
|
923
943
|
end
|
924
944
|
|
@@ -933,7 +953,7 @@ describe Mongoid::Relations::Metadata do
|
|
933
953
|
end
|
934
954
|
|
935
955
|
it "returns an empty array" do
|
936
|
-
metadata.foreign_key_default.
|
956
|
+
expect(metadata.foreign_key_default).to be_nil
|
937
957
|
end
|
938
958
|
end
|
939
959
|
end
|
@@ -951,7 +971,7 @@ describe Mongoid::Relations::Metadata do
|
|
951
971
|
end
|
952
972
|
|
953
973
|
it "returns the foreign_key plus =" do
|
954
|
-
metadata.foreign_key_setter.
|
974
|
+
expect(metadata.foreign_key_setter).to eq("person_id=")
|
955
975
|
end
|
956
976
|
end
|
957
977
|
|
@@ -967,7 +987,7 @@ describe Mongoid::Relations::Metadata do
|
|
967
987
|
end
|
968
988
|
|
969
989
|
it "returns the polymorphic foreign_key plus =" do
|
970
|
-
metadata.foreign_key_setter.
|
990
|
+
expect(metadata.foreign_key_setter).to eq("ratable_id=")
|
971
991
|
end
|
972
992
|
end
|
973
993
|
end
|
@@ -985,7 +1005,7 @@ describe Mongoid::Relations::Metadata do
|
|
985
1005
|
end
|
986
1006
|
|
987
1007
|
it "returns nil" do
|
988
|
-
metadata.inverse_type.
|
1008
|
+
expect(metadata.inverse_type).to be_nil
|
989
1009
|
end
|
990
1010
|
end
|
991
1011
|
|
@@ -1001,7 +1021,7 @@ describe Mongoid::Relations::Metadata do
|
|
1001
1021
|
end
|
1002
1022
|
|
1003
1023
|
it "returns the polymorphic name plus type" do
|
1004
|
-
metadata.inverse_type.
|
1024
|
+
expect(metadata.inverse_type).to eq("ratable_type")
|
1005
1025
|
end
|
1006
1026
|
end
|
1007
1027
|
end
|
@@ -1019,7 +1039,7 @@ describe Mongoid::Relations::Metadata do
|
|
1019
1039
|
end
|
1020
1040
|
|
1021
1041
|
it "returns nil" do
|
1022
|
-
metadata.inverse_type_setter.
|
1042
|
+
expect(metadata.inverse_type_setter).to be_nil
|
1023
1043
|
end
|
1024
1044
|
end
|
1025
1045
|
|
@@ -1035,75 +1055,7 @@ describe Mongoid::Relations::Metadata do
|
|
1035
1055
|
end
|
1036
1056
|
|
1037
1057
|
it "returns the inverse type plus =" do
|
1038
|
-
metadata.inverse_type_setter.
|
1039
|
-
end
|
1040
|
-
end
|
1041
|
-
end
|
1042
|
-
|
1043
|
-
describe "#inverse_of_field" do
|
1044
|
-
|
1045
|
-
context "when the relation is not polymorphic" do
|
1046
|
-
|
1047
|
-
let(:metadata) do
|
1048
|
-
described_class.new(
|
1049
|
-
name: :person,
|
1050
|
-
relation: Mongoid::Relations::Referenced::In,
|
1051
|
-
foreign_key: "person_id"
|
1052
|
-
)
|
1053
|
-
end
|
1054
|
-
|
1055
|
-
it "returns nil" do
|
1056
|
-
metadata.inverse_of_field.should be_nil
|
1057
|
-
end
|
1058
|
-
end
|
1059
|
-
|
1060
|
-
context "when the relation is polymorphic" do
|
1061
|
-
|
1062
|
-
let(:metadata) do
|
1063
|
-
described_class.new(
|
1064
|
-
name: :ratable,
|
1065
|
-
relation: Mongoid::Relations::Referenced::In,
|
1066
|
-
polymorphic: true,
|
1067
|
-
inverse_class_name: "Rating"
|
1068
|
-
)
|
1069
|
-
end
|
1070
|
-
|
1071
|
-
it "returns the polymorphic name plus field" do
|
1072
|
-
metadata.inverse_of_field.should eq("ratable_field")
|
1073
|
-
end
|
1074
|
-
end
|
1075
|
-
end
|
1076
|
-
|
1077
|
-
describe "#inverse_of_field_setter" do
|
1078
|
-
|
1079
|
-
context "when the relation is not polymorphic" do
|
1080
|
-
|
1081
|
-
let(:metadata) do
|
1082
|
-
described_class.new(
|
1083
|
-
name: :person,
|
1084
|
-
relation: Mongoid::Relations::Referenced::In,
|
1085
|
-
foreign_key: "person_id"
|
1086
|
-
)
|
1087
|
-
end
|
1088
|
-
|
1089
|
-
it "returns nil" do
|
1090
|
-
metadata.inverse_of_field_setter.should be_nil
|
1091
|
-
end
|
1092
|
-
end
|
1093
|
-
|
1094
|
-
context "when the relation is polymorphic" do
|
1095
|
-
|
1096
|
-
let(:metadata) do
|
1097
|
-
described_class.new(
|
1098
|
-
name: :ratable,
|
1099
|
-
relation: Mongoid::Relations::Referenced::In,
|
1100
|
-
polymorphic: true,
|
1101
|
-
inverse_class_name: "Rating"
|
1102
|
-
)
|
1103
|
-
end
|
1104
|
-
|
1105
|
-
it "returns the inverse of field plus =" do
|
1106
|
-
metadata.inverse_of_field_setter.should eq("ratable_field=")
|
1058
|
+
expect(metadata.inverse_type_setter).to eq("ratable_type=")
|
1107
1059
|
end
|
1108
1060
|
end
|
1109
1061
|
end
|
@@ -1124,7 +1076,7 @@ describe Mongoid::Relations::Metadata do
|
|
1124
1076
|
end
|
1125
1077
|
|
1126
1078
|
it "returns only the inverse_of" do
|
1127
|
-
metadata.inverses(nil).
|
1079
|
+
expect(metadata.inverses(nil)).to eq([ "my_ratings" ])
|
1128
1080
|
end
|
1129
1081
|
end
|
1130
1082
|
end
|
@@ -1142,7 +1094,7 @@ describe Mongoid::Relations::Metadata do
|
|
1142
1094
|
end
|
1143
1095
|
|
1144
1096
|
it "returns true" do
|
1145
|
-
metadata.indexed
|
1097
|
+
expect(metadata.indexed?).to be true
|
1146
1098
|
end
|
1147
1099
|
end
|
1148
1100
|
|
@@ -1155,7 +1107,7 @@ describe Mongoid::Relations::Metadata do
|
|
1155
1107
|
end
|
1156
1108
|
|
1157
1109
|
it "returns false" do
|
1158
|
-
metadata.indexed
|
1110
|
+
expect(metadata.indexed?).to be false
|
1159
1111
|
end
|
1160
1112
|
end
|
1161
1113
|
|
@@ -1169,7 +1121,7 @@ describe Mongoid::Relations::Metadata do
|
|
1169
1121
|
end
|
1170
1122
|
|
1171
1123
|
it "returns false" do
|
1172
|
-
metadata.indexed
|
1124
|
+
expect(metadata.indexed?).to be false
|
1173
1125
|
end
|
1174
1126
|
end
|
1175
1127
|
end
|
@@ -1185,7 +1137,7 @@ describe Mongoid::Relations::Metadata do
|
|
1185
1137
|
end
|
1186
1138
|
|
1187
1139
|
it "returns the name of the inverse with the matching foreign_key" do
|
1188
|
-
metadata.inverse.
|
1140
|
+
expect(metadata.inverse).to eq(:creator)
|
1189
1141
|
end
|
1190
1142
|
end
|
1191
1143
|
|
@@ -1202,7 +1154,7 @@ describe Mongoid::Relations::Metadata do
|
|
1202
1154
|
end
|
1203
1155
|
|
1204
1156
|
it "returns the name of the inverse with the matching inverse of" do
|
1205
|
-
metadata.inverse.
|
1157
|
+
expect(metadata.inverse).to eq(:user)
|
1206
1158
|
end
|
1207
1159
|
end
|
1208
1160
|
|
@@ -1219,7 +1171,7 @@ describe Mongoid::Relations::Metadata do
|
|
1219
1171
|
end
|
1220
1172
|
|
1221
1173
|
it "returns the name of the relation" do
|
1222
|
-
metadata.inverse.
|
1174
|
+
expect(metadata.inverse).to eq(:eyeable)
|
1223
1175
|
end
|
1224
1176
|
end
|
1225
1177
|
|
@@ -1235,7 +1187,7 @@ describe Mongoid::Relations::Metadata do
|
|
1235
1187
|
end
|
1236
1188
|
|
1237
1189
|
it "returns nil" do
|
1238
|
-
metadata.inverse(Face.new).
|
1190
|
+
expect(metadata.inverse(Face.new)).to be_nil
|
1239
1191
|
end
|
1240
1192
|
end
|
1241
1193
|
end
|
@@ -1252,7 +1204,7 @@ describe Mongoid::Relations::Metadata do
|
|
1252
1204
|
end
|
1253
1205
|
|
1254
1206
|
it "returns nil" do
|
1255
|
-
metadata.inverse.
|
1207
|
+
expect(metadata.inverse).to be_nil
|
1256
1208
|
end
|
1257
1209
|
end
|
1258
1210
|
|
@@ -1266,7 +1218,7 @@ describe Mongoid::Relations::Metadata do
|
|
1266
1218
|
end
|
1267
1219
|
|
1268
1220
|
it "returns the name of the inverse_of property" do
|
1269
|
-
metadata.inverse.
|
1221
|
+
expect(metadata.inverse).to eq(:crazy_name)
|
1270
1222
|
end
|
1271
1223
|
end
|
1272
1224
|
end
|
@@ -1283,7 +1235,7 @@ describe Mongoid::Relations::Metadata do
|
|
1283
1235
|
end
|
1284
1236
|
|
1285
1237
|
it "returns the name of the relation" do
|
1286
|
-
metadata.inverse.
|
1238
|
+
expect(metadata.inverse).to eq(:person)
|
1287
1239
|
end
|
1288
1240
|
end
|
1289
1241
|
|
@@ -1299,7 +1251,7 @@ describe Mongoid::Relations::Metadata do
|
|
1299
1251
|
end
|
1300
1252
|
|
1301
1253
|
it "returns the name of the relation" do
|
1302
|
-
metadata.inverse.
|
1254
|
+
expect(metadata.inverse).to eq(:addressable)
|
1303
1255
|
end
|
1304
1256
|
end
|
1305
1257
|
|
@@ -1315,7 +1267,7 @@ describe Mongoid::Relations::Metadata do
|
|
1315
1267
|
end
|
1316
1268
|
|
1317
1269
|
it "returns the name of the relation" do
|
1318
|
-
metadata.inverse(Person.new).
|
1270
|
+
expect(metadata.inverse(Person.new)).to eq(:addresses)
|
1319
1271
|
end
|
1320
1272
|
end
|
1321
1273
|
|
@@ -1334,7 +1286,7 @@ describe Mongoid::Relations::Metadata do
|
|
1334
1286
|
end
|
1335
1287
|
|
1336
1288
|
it "returns the name of the relation" do
|
1337
|
-
metadata.inverse(Role.new).
|
1289
|
+
expect(metadata.inverse(Role.new)).to eq(:child_roles)
|
1338
1290
|
end
|
1339
1291
|
end
|
1340
1292
|
|
@@ -1351,7 +1303,7 @@ describe Mongoid::Relations::Metadata do
|
|
1351
1303
|
end
|
1352
1304
|
|
1353
1305
|
it "returns the name of the relation" do
|
1354
|
-
metadata.inverse(Entry.new).
|
1306
|
+
expect(metadata.inverse(Entry.new)).to eq(:child_entries)
|
1355
1307
|
end
|
1356
1308
|
end
|
1357
1309
|
end
|
@@ -1373,7 +1325,7 @@ describe Mongoid::Relations::Metadata do
|
|
1373
1325
|
end
|
1374
1326
|
|
1375
1327
|
it "returns the inverse class name plus suffix" do
|
1376
|
-
metadata.inverse_foreign_key.
|
1328
|
+
expect(metadata.inverse_foreign_key).to eq("person_ids")
|
1377
1329
|
end
|
1378
1330
|
end
|
1379
1331
|
|
@@ -1389,7 +1341,7 @@ describe Mongoid::Relations::Metadata do
|
|
1389
1341
|
end
|
1390
1342
|
|
1391
1343
|
it "returns nil" do
|
1392
|
-
metadata.inverse_foreign_key.
|
1344
|
+
expect(metadata.inverse_foreign_key).to be_nil
|
1393
1345
|
end
|
1394
1346
|
end
|
1395
1347
|
end
|
@@ -1404,7 +1356,7 @@ describe Mongoid::Relations::Metadata do
|
|
1404
1356
|
end
|
1405
1357
|
|
1406
1358
|
it "constantizes the inverse_class_name" do
|
1407
|
-
metadata.inverse_klass.
|
1359
|
+
expect(metadata.inverse_klass).to eq(Person)
|
1408
1360
|
end
|
1409
1361
|
end
|
1410
1362
|
|
@@ -1422,7 +1374,7 @@ describe Mongoid::Relations::Metadata do
|
|
1422
1374
|
end
|
1423
1375
|
|
1424
1376
|
it "returns a string for the setter" do
|
1425
|
-
metadata.inverse_setter.
|
1377
|
+
expect(metadata.inverse_setter).to eq("person=")
|
1426
1378
|
end
|
1427
1379
|
end
|
1428
1380
|
|
@@ -1445,7 +1397,7 @@ describe Mongoid::Relations::Metadata do
|
|
1445
1397
|
end
|
1446
1398
|
|
1447
1399
|
it "returns nil" do
|
1448
|
-
metadata.inverse_setter(other).
|
1400
|
+
expect(metadata.inverse_setter(other)).to be_nil
|
1449
1401
|
end
|
1450
1402
|
end
|
1451
1403
|
|
@@ -1461,7 +1413,7 @@ describe Mongoid::Relations::Metadata do
|
|
1461
1413
|
end
|
1462
1414
|
|
1463
1415
|
it "returns a string for the setter" do
|
1464
|
-
metadata.inverse_setter.
|
1416
|
+
expect(metadata.inverse_setter).to eq("eyeable=")
|
1465
1417
|
end
|
1466
1418
|
end
|
1467
1419
|
end
|
@@ -1482,7 +1434,7 @@ describe Mongoid::Relations::Metadata do
|
|
1482
1434
|
end
|
1483
1435
|
|
1484
1436
|
it "returns a string for the setter" do
|
1485
|
-
metadata.inverse_setter(other).
|
1437
|
+
expect(metadata.inverse_setter(other)).to eq("ratings=")
|
1486
1438
|
end
|
1487
1439
|
end
|
1488
1440
|
|
@@ -1498,7 +1450,7 @@ describe Mongoid::Relations::Metadata do
|
|
1498
1450
|
end
|
1499
1451
|
|
1500
1452
|
it "returns a string for the setter" do
|
1501
|
-
metadata.inverse_setter.
|
1453
|
+
expect(metadata.inverse_setter).to eq("ratable=")
|
1502
1454
|
end
|
1503
1455
|
end
|
1504
1456
|
end
|
@@ -1516,7 +1468,7 @@ describe Mongoid::Relations::Metadata do
|
|
1516
1468
|
end
|
1517
1469
|
|
1518
1470
|
it "returns the name as a string" do
|
1519
|
-
metadata.key.
|
1471
|
+
expect(metadata.key).to eq("addresses")
|
1520
1472
|
end
|
1521
1473
|
|
1522
1474
|
context "with a store_as option defined" do
|
@@ -1530,7 +1482,7 @@ describe Mongoid::Relations::Metadata do
|
|
1530
1482
|
end
|
1531
1483
|
|
1532
1484
|
it "return the name define by store_as option" do
|
1533
|
-
metadata.key.
|
1485
|
+
expect(metadata.key).to eq("user_comments")
|
1534
1486
|
end
|
1535
1487
|
end
|
1536
1488
|
end
|
@@ -1549,7 +1501,7 @@ describe Mongoid::Relations::Metadata do
|
|
1549
1501
|
end
|
1550
1502
|
|
1551
1503
|
it "returns the foreign_key" do
|
1552
|
-
metadata.key.
|
1504
|
+
expect(metadata.key).to eq("post_ids")
|
1553
1505
|
end
|
1554
1506
|
end
|
1555
1507
|
|
@@ -1564,7 +1516,7 @@ describe Mongoid::Relations::Metadata do
|
|
1564
1516
|
end
|
1565
1517
|
|
1566
1518
|
it "returns the polymorphic foreign_key" do
|
1567
|
-
metadata.key.
|
1519
|
+
expect(metadata.key).to eq("ratable_id")
|
1568
1520
|
end
|
1569
1521
|
end
|
1570
1522
|
end
|
@@ -1580,7 +1532,7 @@ describe Mongoid::Relations::Metadata do
|
|
1580
1532
|
end
|
1581
1533
|
|
1582
1534
|
it "returns _id" do
|
1583
|
-
metadata.key.
|
1535
|
+
expect(metadata.key).to eq("_id")
|
1584
1536
|
end
|
1585
1537
|
end
|
1586
1538
|
end
|
@@ -1596,7 +1548,7 @@ describe Mongoid::Relations::Metadata do
|
|
1596
1548
|
end
|
1597
1549
|
|
1598
1550
|
it "returns self" do
|
1599
|
-
metadata.options.
|
1551
|
+
expect(metadata.options).to eq(metadata)
|
1600
1552
|
end
|
1601
1553
|
end
|
1602
1554
|
|
@@ -1610,7 +1562,7 @@ describe Mongoid::Relations::Metadata do
|
|
1610
1562
|
end
|
1611
1563
|
|
1612
1564
|
it "returns order criteria" do
|
1613
|
-
metadata.order.
|
1565
|
+
expect(metadata.order).to eq(:rating.asc)
|
1614
1566
|
end
|
1615
1567
|
end
|
1616
1568
|
|
@@ -1626,7 +1578,7 @@ describe Mongoid::Relations::Metadata do
|
|
1626
1578
|
end
|
1627
1579
|
|
1628
1580
|
it "constantizes the class_name" do
|
1629
|
-
metadata.klass.
|
1581
|
+
expect(metadata.klass).to eq(Address)
|
1630
1582
|
end
|
1631
1583
|
end
|
1632
1584
|
|
@@ -1640,7 +1592,7 @@ describe Mongoid::Relations::Metadata do
|
|
1640
1592
|
end
|
1641
1593
|
|
1642
1594
|
it "returns the class" do
|
1643
|
-
metadata.klass.
|
1595
|
+
expect(metadata.klass).to eq(Address)
|
1644
1596
|
end
|
1645
1597
|
end
|
1646
1598
|
end
|
@@ -1654,7 +1606,7 @@ describe Mongoid::Relations::Metadata do
|
|
1654
1606
|
end
|
1655
1607
|
|
1656
1608
|
it "returns true" do
|
1657
|
-
metadata.
|
1609
|
+
expect(metadata).to be_many
|
1658
1610
|
end
|
1659
1611
|
end
|
1660
1612
|
|
@@ -1665,7 +1617,7 @@ describe Mongoid::Relations::Metadata do
|
|
1665
1617
|
end
|
1666
1618
|
|
1667
1619
|
it "returns false" do
|
1668
|
-
metadata.
|
1620
|
+
expect(metadata).to_not be_many
|
1669
1621
|
end
|
1670
1622
|
end
|
1671
1623
|
end
|
@@ -1677,7 +1629,7 @@ describe Mongoid::Relations::Metadata do
|
|
1677
1629
|
end
|
1678
1630
|
|
1679
1631
|
it "returns the macro from the relation" do
|
1680
|
-
metadata.macro.
|
1632
|
+
expect(metadata.macro).to eq(:embeds_one)
|
1681
1633
|
end
|
1682
1634
|
end
|
1683
1635
|
|
@@ -1696,8 +1648,9 @@ describe Mongoid::Relations::Metadata do
|
|
1696
1648
|
end
|
1697
1649
|
|
1698
1650
|
it "returns the nested builder from the relation" do
|
1699
|
-
|
1700
|
-
|
1651
|
+
expect(
|
1652
|
+
metadata.nested_builder(attributes, options)
|
1653
|
+
).to be_a_kind_of(Mongoid::Relations::Builders::NestedAttributes::One)
|
1701
1654
|
end
|
1702
1655
|
end
|
1703
1656
|
|
@@ -1714,7 +1667,7 @@ describe Mongoid::Relations::Metadata do
|
|
1714
1667
|
end
|
1715
1668
|
|
1716
1669
|
it "returns _id" do
|
1717
|
-
metadata.primary_key.
|
1670
|
+
expect(metadata.primary_key).to eq("_id")
|
1718
1671
|
end
|
1719
1672
|
end
|
1720
1673
|
|
@@ -1730,7 +1683,7 @@ describe Mongoid::Relations::Metadata do
|
|
1730
1683
|
end
|
1731
1684
|
|
1732
1685
|
it "returns the primary key" do
|
1733
|
-
metadata.primary_key.
|
1686
|
+
expect(metadata.primary_key).to eq("something_id")
|
1734
1687
|
end
|
1735
1688
|
end
|
1736
1689
|
end
|
@@ -1751,7 +1704,7 @@ describe Mongoid::Relations::Metadata do
|
|
1751
1704
|
end
|
1752
1705
|
|
1753
1706
|
it "returns true" do
|
1754
|
-
metadata.validate
|
1707
|
+
expect(metadata.validate?).to be true
|
1755
1708
|
end
|
1756
1709
|
end
|
1757
1710
|
|
@@ -1767,7 +1720,7 @@ describe Mongoid::Relations::Metadata do
|
|
1767
1720
|
end
|
1768
1721
|
|
1769
1722
|
it "returns false" do
|
1770
|
-
metadata.validate
|
1723
|
+
expect(metadata.validate?).to be false
|
1771
1724
|
end
|
1772
1725
|
end
|
1773
1726
|
end
|
@@ -1783,54 +1736,7 @@ describe Mongoid::Relations::Metadata do
|
|
1783
1736
|
end
|
1784
1737
|
|
1785
1738
|
it "returns the relation default" do
|
1786
|
-
metadata.validate
|
1787
|
-
end
|
1788
|
-
end
|
1789
|
-
end
|
1790
|
-
|
1791
|
-
describe "#versioned?" do
|
1792
|
-
|
1793
|
-
context "when versioned is true" do
|
1794
|
-
|
1795
|
-
let(:metadata) do
|
1796
|
-
described_class.new(
|
1797
|
-
name: :versions,
|
1798
|
-
relation: Mongoid::Relations::Embedded::Many,
|
1799
|
-
versioned: true
|
1800
|
-
)
|
1801
|
-
end
|
1802
|
-
|
1803
|
-
it "returns true" do
|
1804
|
-
metadata.should be_versioned
|
1805
|
-
end
|
1806
|
-
end
|
1807
|
-
|
1808
|
-
context "when versioned is false" do
|
1809
|
-
|
1810
|
-
let(:metadata) do
|
1811
|
-
described_class.new(
|
1812
|
-
name: :versions,
|
1813
|
-
relation: Mongoid::Relations::Embedded::Many,
|
1814
|
-
versioned: false
|
1815
|
-
)
|
1816
|
-
end
|
1817
|
-
|
1818
|
-
it "returns false" do
|
1819
|
-
metadata.should_not be_versioned
|
1820
|
-
end
|
1821
|
-
end
|
1822
|
-
|
1823
|
-
context "when versioned is nil" do
|
1824
|
-
|
1825
|
-
let(:metadata) do
|
1826
|
-
described_class.new(
|
1827
|
-
name: :versions,
|
1828
|
-
relation: Mongoid::Relations::Embedded::Many
|
1829
|
-
)
|
1830
|
-
end
|
1831
|
-
|
1832
|
-
it "returns false" do
|
1833
|
-
metadata.should_not be_versioned
|
1739
|
+
expect(metadata.validate?).to be true
|
1834
1740
|
end
|
1835
1741
|
end
|
1836
1742
|
end
|
@@ -1848,7 +1754,7 @@ describe Mongoid::Relations::Metadata do
|
|
1848
1754
|
end
|
1849
1755
|
|
1850
1756
|
it "returns the value" do
|
1851
|
-
metadata.store_as.
|
1757
|
+
expect(metadata.store_as).to eq("user_comments")
|
1852
1758
|
end
|
1853
1759
|
end
|
1854
1760
|
|
@@ -1862,7 +1768,7 @@ describe Mongoid::Relations::Metadata do
|
|
1862
1768
|
end
|
1863
1769
|
|
1864
1770
|
it "returns false" do
|
1865
|
-
metadata.store_as.
|
1771
|
+
expect(metadata.store_as).to eq("comments")
|
1866
1772
|
end
|
1867
1773
|
end
|
1868
1774
|
end
|
@@ -1893,14 +1799,14 @@ describe Mongoid::Relations::Metadata do
|
|
1893
1799
|
end
|
1894
1800
|
|
1895
1801
|
it "returns nil" do
|
1896
|
-
inverse_relation.
|
1802
|
+
expect(inverse_relation).to be_nil
|
1897
1803
|
end
|
1898
1804
|
end
|
1899
1805
|
|
1900
1806
|
context "when one match" do
|
1901
1807
|
|
1902
1808
|
it "returns correct relation" do
|
1903
|
-
inverse_relation.
|
1809
|
+
expect(inverse_relation).to eq(:drugs)
|
1904
1810
|
end
|
1905
1811
|
end
|
1906
1812
|
|
@@ -1936,7 +1842,7 @@ describe Mongoid::Relations::Metadata do
|
|
1936
1842
|
end
|
1937
1843
|
|
1938
1844
|
it "returns false" do
|
1939
|
-
metadata.
|
1845
|
+
expect(metadata).to_not be_touchable
|
1940
1846
|
end
|
1941
1847
|
end
|
1942
1848
|
|
@@ -1951,7 +1857,7 @@ describe Mongoid::Relations::Metadata do
|
|
1951
1857
|
end
|
1952
1858
|
|
1953
1859
|
it "returns true" do
|
1954
|
-
metadata.
|
1860
|
+
expect(metadata).to be_touchable
|
1955
1861
|
end
|
1956
1862
|
end
|
1957
1863
|
|
@@ -1965,7 +1871,7 @@ describe Mongoid::Relations::Metadata do
|
|
1965
1871
|
end
|
1966
1872
|
|
1967
1873
|
it "returns false" do
|
1968
|
-
metadata.
|
1874
|
+
expect(metadata).to_not be_touchable
|
1969
1875
|
end
|
1970
1876
|
end
|
1971
1877
|
end
|
@@ -1991,7 +1897,7 @@ describe Mongoid::Relations::Metadata do
|
|
1991
1897
|
end
|
1992
1898
|
|
1993
1899
|
it "returns the #{property} property" do
|
1994
|
-
metadata.send(property).
|
1900
|
+
expect(metadata.send(property)).to eq(:value)
|
1995
1901
|
end
|
1996
1902
|
end
|
1997
1903
|
|
@@ -2007,7 +1913,7 @@ describe Mongoid::Relations::Metadata do
|
|
2007
1913
|
end
|
2008
1914
|
|
2009
1915
|
it "returns true" do
|
2010
|
-
metadata.send("#{property}?").
|
1916
|
+
expect(metadata.send("#{property}?")).to be true
|
2011
1917
|
end
|
2012
1918
|
end
|
2013
1919
|
|
@@ -2020,7 +1926,7 @@ describe Mongoid::Relations::Metadata do
|
|
2020
1926
|
end
|
2021
1927
|
|
2022
1928
|
it "returns false" do
|
2023
|
-
metadata.send("#{property}?").
|
1929
|
+
expect(metadata.send("#{property}?")).to be false
|
2024
1930
|
end
|
2025
1931
|
end
|
2026
1932
|
end
|