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
@@ -27,7 +27,7 @@ describe Mongoid::Relations::Reflections do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns the association metadata" do
|
30
|
-
relation.macro.
|
30
|
+
expect(relation.macro).to eq(:embeds_many)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -38,7 +38,7 @@ describe Mongoid::Relations::Reflections do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "returns nil" do
|
41
|
-
relation.
|
41
|
+
expect(relation).to be_nil
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -60,7 +60,7 @@ describe Mongoid::Relations::Reflections do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "returns an array of the relations" do
|
63
|
-
relations.size.
|
63
|
+
expect(relations.size).to eq(2)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -71,7 +71,7 @@ describe Mongoid::Relations::Reflections do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it "returns an array of the relations" do
|
74
|
-
relations.size.
|
74
|
+
expect(relations.size).to eq(1)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -83,7 +83,7 @@ describe Mongoid::Relations::Reflections do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "returns an empty array" do
|
86
|
-
relations.
|
86
|
+
expect(relations).to be_empty
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -94,7 +94,7 @@ describe Mongoid::Relations::Reflections do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
it "returns an empty array" do
|
97
|
-
relations.
|
97
|
+
expect(relations).to be_empty
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -37,30 +37,30 @@ describe Mongoid::Relations::Synchronization do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
it "has persisted :agent" do
|
40
|
-
agent.persisted
|
40
|
+
expect(agent.persisted?).to be true
|
41
41
|
end
|
42
42
|
|
43
43
|
it "has persisted :user" do
|
44
|
-
user.persisted
|
44
|
+
expect(user.persisted?).to be true
|
45
45
|
end
|
46
46
|
|
47
47
|
it "has persisted :person" do
|
48
|
-
person.persisted
|
48
|
+
expect(person.persisted?).to be true
|
49
49
|
end
|
50
50
|
|
51
51
|
it "does not have persisted :account" do
|
52
|
-
account.persisted
|
52
|
+
expect(account.persisted?).to be false
|
53
53
|
end
|
54
54
|
|
55
55
|
it "has instantiated a .valid? :account" do
|
56
56
|
account.valid?
|
57
|
-
account.valid
|
57
|
+
expect(account.valid?).to be true
|
58
58
|
end
|
59
59
|
|
60
60
|
context "and is Persisted" do
|
61
61
|
|
62
62
|
it "is able to :save" do
|
63
|
-
account.save.
|
63
|
+
expect(account.save).to be true
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -71,7 +71,7 @@ describe Mongoid::Relations::Synchronization do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it "is able to :save" do
|
74
|
-
account.save.
|
74
|
+
expect(account.save).to be true
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -92,11 +92,11 @@ describe Mongoid::Relations::Synchronization do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it "does not attempt synchronization" do
|
95
|
-
expect { article.save }.to_not raise_error
|
95
|
+
expect { article.save }.to_not raise_error
|
96
96
|
end
|
97
97
|
|
98
98
|
it "sets the one side of the relation" do
|
99
|
-
article.preferences.
|
99
|
+
expect(article.preferences).to eq([ preference ])
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -115,11 +115,11 @@ describe Mongoid::Relations::Synchronization do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
it "sets the inverse foreign key" do
|
118
|
-
one.person_ids.
|
118
|
+
expect(one.person_ids).to eq([ person.id ])
|
119
119
|
end
|
120
120
|
|
121
121
|
it "resets the synced flag" do
|
122
|
-
person.synced["preference_ids"].
|
122
|
+
expect(person.synced["preference_ids"]).to be false
|
123
123
|
end
|
124
124
|
|
125
125
|
context "when subsequently setting with keys" do
|
@@ -134,7 +134,7 @@ describe Mongoid::Relations::Synchronization do
|
|
134
134
|
end
|
135
135
|
|
136
136
|
it "sets the inverse foreign key" do
|
137
|
-
two.reload.person_ids.
|
137
|
+
expect(two.reload.person_ids).to eq([ person.id ])
|
138
138
|
end
|
139
139
|
end
|
140
140
|
end
|
@@ -158,15 +158,15 @@ describe Mongoid::Relations::Synchronization do
|
|
158
158
|
end
|
159
159
|
|
160
160
|
it "sets the foreign_key" do
|
161
|
-
person.preference_ids.
|
161
|
+
expect(person.preference_ids).to eq([ one.id, two.id ])
|
162
162
|
end
|
163
163
|
|
164
164
|
it "does not set the first inverse key" do
|
165
|
-
one.reload.person_ids.
|
165
|
+
expect(one.reload.person_ids).to be_empty
|
166
166
|
end
|
167
167
|
|
168
168
|
it "does not set the second inverse key" do
|
169
|
-
two.reload.person_ids.
|
169
|
+
expect(two.reload.person_ids).to be_empty
|
170
170
|
end
|
171
171
|
|
172
172
|
context "when saving the base" do
|
@@ -178,15 +178,15 @@ describe Mongoid::Relations::Synchronization do
|
|
178
178
|
end
|
179
179
|
|
180
180
|
it "persists the foreign_key" do
|
181
|
-
person.reload.preference_ids.
|
181
|
+
expect(person.reload.preference_ids).to eq([ one.id, two.id ])
|
182
182
|
end
|
183
183
|
|
184
184
|
it "sets the first inverse key" do
|
185
|
-
one.reload.person_ids.
|
185
|
+
expect(one.reload.person_ids).to eq([ person.id ])
|
186
186
|
end
|
187
187
|
|
188
188
|
it "sets the second inverse key" do
|
189
|
-
two.reload.person_ids.
|
189
|
+
expect(two.reload.person_ids).to eq([ person.id ])
|
190
190
|
end
|
191
191
|
end
|
192
192
|
end
|
@@ -215,19 +215,19 @@ describe Mongoid::Relations::Synchronization do
|
|
215
215
|
end
|
216
216
|
|
217
217
|
it "sets the foreign_key" do
|
218
|
-
person.preference_ids.
|
218
|
+
expect(person.preference_ids).to eq([ three.id ])
|
219
219
|
end
|
220
220
|
|
221
221
|
it "does not remove the first inverse key" do
|
222
|
-
one.reload.person_ids.
|
222
|
+
expect(one.reload.person_ids).to eq([ person.id ])
|
223
223
|
end
|
224
224
|
|
225
225
|
it "does not remove the second inverse key" do
|
226
|
-
two.reload.person_ids.
|
226
|
+
expect(two.reload.person_ids).to eq([ person.id ])
|
227
227
|
end
|
228
228
|
|
229
229
|
it "does not set the third inverse key" do
|
230
|
-
three.reload.person_ids.
|
230
|
+
expect(three.reload.person_ids).to be_empty
|
231
231
|
end
|
232
232
|
|
233
233
|
context "when saving the base" do
|
@@ -239,19 +239,19 @@ describe Mongoid::Relations::Synchronization do
|
|
239
239
|
end
|
240
240
|
|
241
241
|
it "persists the foreign_key" do
|
242
|
-
person.reload.preference_ids.
|
242
|
+
expect(person.reload.preference_ids).to eq([ three.id ])
|
243
243
|
end
|
244
244
|
|
245
245
|
it "removes the first inverse key" do
|
246
|
-
one.reload.person_ids.
|
246
|
+
expect(one.reload.person_ids).to be_empty
|
247
247
|
end
|
248
248
|
|
249
249
|
it "removes the second inverse key" do
|
250
|
-
two.reload.person_ids.
|
250
|
+
expect(two.reload.person_ids).to be_empty
|
251
251
|
end
|
252
252
|
|
253
253
|
it "sets the third inverse key" do
|
254
|
-
three.reload.person_ids.
|
254
|
+
expect(three.reload.person_ids).to eq([ person.id ])
|
255
255
|
end
|
256
256
|
end
|
257
257
|
end
|
@@ -276,15 +276,15 @@ describe Mongoid::Relations::Synchronization do
|
|
276
276
|
end
|
277
277
|
|
278
278
|
it "sets the foreign_key" do
|
279
|
-
person.preference_ids.
|
279
|
+
expect(person.preference_ids).to be_empty
|
280
280
|
end
|
281
281
|
|
282
282
|
it "does not remove the first inverse key" do
|
283
|
-
one.reload.person_ids.
|
283
|
+
expect(one.reload.person_ids).to eq([ person.id ])
|
284
284
|
end
|
285
285
|
|
286
286
|
it "does not remove the second inverse key" do
|
287
|
-
two.reload.person_ids.
|
287
|
+
expect(two.reload.person_ids).to eq([ person.id ])
|
288
288
|
end
|
289
289
|
|
290
290
|
context "when saving the base" do
|
@@ -296,15 +296,15 @@ describe Mongoid::Relations::Synchronization do
|
|
296
296
|
end
|
297
297
|
|
298
298
|
it "persists the foreign_key" do
|
299
|
-
person.reload.preference_ids.
|
299
|
+
expect(person.reload.preference_ids).to be_empty
|
300
300
|
end
|
301
301
|
|
302
302
|
it "removes the first inverse key" do
|
303
|
-
one.reload.person_ids.
|
303
|
+
expect(one.reload.person_ids).to be_empty
|
304
304
|
end
|
305
305
|
|
306
306
|
it "removes the second inverse key" do
|
307
|
-
two.reload.person_ids.
|
307
|
+
expect(two.reload.person_ids).to be_empty
|
308
308
|
end
|
309
309
|
end
|
310
310
|
end
|
@@ -329,15 +329,15 @@ describe Mongoid::Relations::Synchronization do
|
|
329
329
|
end
|
330
330
|
|
331
331
|
it "sets the foreign_key" do
|
332
|
-
person.preference_ids.
|
332
|
+
expect(person.preference_ids).to be_empty
|
333
333
|
end
|
334
334
|
|
335
335
|
it "does not remove the first inverse key" do
|
336
|
-
one.reload.person_ids.
|
336
|
+
expect(one.reload.person_ids).to eq([ person.id ])
|
337
337
|
end
|
338
338
|
|
339
339
|
it "does not remove the second inverse key" do
|
340
|
-
two.reload.person_ids.
|
340
|
+
expect(two.reload.person_ids).to eq([ person.id ])
|
341
341
|
end
|
342
342
|
|
343
343
|
context "when saving the base" do
|
@@ -349,15 +349,15 @@ describe Mongoid::Relations::Synchronization do
|
|
349
349
|
end
|
350
350
|
|
351
351
|
it "persists the foreign_key" do
|
352
|
-
person.reload.preference_ids.
|
352
|
+
expect(person.reload.preference_ids).to be_empty
|
353
353
|
end
|
354
354
|
|
355
355
|
it "removes the first inverse key" do
|
356
|
-
one.reload.person_ids.
|
356
|
+
expect(one.reload.person_ids).to be_empty
|
357
357
|
end
|
358
358
|
|
359
359
|
it "removes the second inverse key" do
|
360
|
-
two.reload.person_ids.
|
360
|
+
expect(two.reload.person_ids).to be_empty
|
361
361
|
end
|
362
362
|
end
|
363
363
|
end
|
@@ -384,11 +384,11 @@ describe Mongoid::Relations::Synchronization do
|
|
384
384
|
end
|
385
385
|
|
386
386
|
it "removes the first inverse key" do
|
387
|
-
one.reload.person_ids.
|
387
|
+
expect(one.reload.person_ids).to be_empty
|
388
388
|
end
|
389
389
|
|
390
390
|
it "removes the second inverse key" do
|
391
|
-
two.reload.person_ids.
|
391
|
+
expect(two.reload.person_ids).to be_empty
|
392
392
|
end
|
393
393
|
end
|
394
394
|
|
@@ -399,14 +399,14 @@ describe Mongoid::Relations::Synchronization do
|
|
399
399
|
end
|
400
400
|
|
401
401
|
it "removes the inverse key" do
|
402
|
-
person.reload.preference_ids.
|
402
|
+
expect(person.reload.preference_ids).to eq([ two.id ])
|
403
403
|
end
|
404
404
|
end
|
405
405
|
end
|
406
406
|
|
407
407
|
context "when appending an existing document to a new one" do
|
408
408
|
|
409
|
-
let!(:
|
409
|
+
let!(:persisted) do
|
410
410
|
Tag.create
|
411
411
|
end
|
412
412
|
|
@@ -415,20 +415,16 @@ describe Mongoid::Relations::Synchronization do
|
|
415
415
|
end
|
416
416
|
|
417
417
|
before do
|
418
|
-
article.tags <<
|
418
|
+
article.tags << persisted
|
419
419
|
article.save
|
420
420
|
end
|
421
421
|
|
422
|
-
let(:tag) do
|
423
|
-
Tag.first
|
424
|
-
end
|
425
|
-
|
426
422
|
it "persists the foreign key on the inverse" do
|
427
|
-
|
423
|
+
expect(persisted.article_ids).to eq([ article.id ])
|
428
424
|
end
|
429
425
|
|
430
426
|
it "persists the inverse relation" do
|
431
|
-
|
427
|
+
expect(persisted.articles).to eq([ article ])
|
432
428
|
end
|
433
429
|
end
|
434
430
|
|
@@ -447,7 +443,7 @@ describe Mongoid::Relations::Synchronization do
|
|
447
443
|
end
|
448
444
|
|
449
445
|
it "adds the id to the inverse relation" do
|
450
|
-
dog.reload.breed_ids.
|
446
|
+
expect(dog.reload.breed_ids).to eq([ breed.id ])
|
451
447
|
end
|
452
448
|
end
|
453
449
|
end
|
@@ -25,7 +25,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns the equality check" do
|
28
|
-
enumerable.
|
28
|
+
expect(enumerable).to eq([ post ])
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -36,7 +36,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns the equality check" do
|
39
|
-
enumerable._loaded.values.
|
39
|
+
expect(enumerable._loaded.values).to eq([ post ])
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -61,7 +61,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it "returns the equality check" do
|
64
|
-
enumerable.
|
64
|
+
expect(enumerable).to eq([ post, post_two ])
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -72,7 +72,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "returns the equality check" do
|
75
|
-
enumerable.
|
75
|
+
expect(enumerable).to eq([ post ])
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -90,7 +90,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "returns the equality check" do
|
93
|
-
enumerable.
|
93
|
+
expect(enumerable).to eq([ post ])
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
@@ -104,7 +104,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
it "returns false" do
|
107
|
-
enumerable.
|
107
|
+
expect(enumerable).to_not eq("person")
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -118,14 +118,14 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
118
118
|
context "when compared to an array class" do
|
119
119
|
|
120
120
|
it "returns true" do
|
121
|
-
expect(enumerable === Array).to
|
121
|
+
expect(enumerable === Array).to be true
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
125
|
context "when compared to a different class" do
|
126
126
|
|
127
127
|
it "returns false" do
|
128
|
-
expect(enumerable === Mongoid::Document).to
|
128
|
+
expect(enumerable === Mongoid::Document).to be false
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -138,7 +138,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
138
138
|
end
|
139
139
|
|
140
140
|
it "returns true" do
|
141
|
-
expect(enumerable === other).to
|
141
|
+
expect(enumerable === other).to be true
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
@@ -149,7 +149,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
it "returns false" do
|
152
|
-
expect(enumerable === other).to
|
152
|
+
expect(enumerable === other).to be false
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
@@ -176,11 +176,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
176
176
|
end
|
177
177
|
|
178
178
|
it "adds the document to the added target" do
|
179
|
-
enumerable._added.
|
179
|
+
expect(enumerable._added).to eq({ post.id => post })
|
180
180
|
end
|
181
181
|
|
182
182
|
it "returns the added documents" do
|
183
|
-
added.
|
183
|
+
expect(added).to eq([ post ])
|
184
184
|
end
|
185
185
|
end
|
186
186
|
end
|
@@ -214,15 +214,15 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it "returns true" do
|
217
|
-
any.
|
217
|
+
expect(any).to be true
|
218
218
|
end
|
219
219
|
|
220
220
|
it "retains the correct length" do
|
221
|
-
enumerable.length.
|
221
|
+
expect(enumerable.length).to eq(2)
|
222
222
|
end
|
223
223
|
|
224
224
|
it "retains the correct length when calling to_a" do
|
225
|
-
enumerable.to_a.length.
|
225
|
+
expect(enumerable.to_a.length).to eq(2)
|
226
226
|
end
|
227
227
|
|
228
228
|
context "when iterating over the relation a second time" do
|
@@ -232,11 +232,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
232
232
|
end
|
233
233
|
|
234
234
|
it "retains the correct length" do
|
235
|
-
enumerable.length.
|
235
|
+
expect(enumerable.length).to eq(2)
|
236
236
|
end
|
237
237
|
|
238
238
|
it "retains the correct length when calling to_a" do
|
239
|
-
enumerable.to_a.length.
|
239
|
+
expect(enumerable.to_a.length).to eq(2)
|
240
240
|
end
|
241
241
|
end
|
242
242
|
end
|
@@ -271,20 +271,20 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
271
271
|
|
272
272
|
let!(:clear) do
|
273
273
|
enumerable.clear do |doc|
|
274
|
-
doc.
|
274
|
+
expect(doc).to be_a(Post)
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
278
|
it "clears out the loaded docs" do
|
279
|
-
enumerable._loaded.
|
279
|
+
expect(enumerable._loaded).to be_empty
|
280
280
|
end
|
281
281
|
|
282
282
|
it "clears out the added docs" do
|
283
|
-
enumerable._added.
|
283
|
+
expect(enumerable._added).to be_empty
|
284
284
|
end
|
285
285
|
|
286
286
|
it "retains its loaded state" do
|
287
|
-
enumerable.
|
287
|
+
expect(enumerable).to_not be__loaded
|
288
288
|
end
|
289
289
|
end
|
290
290
|
|
@@ -320,11 +320,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
320
320
|
end
|
321
321
|
|
322
322
|
it "does not retain the first id" do
|
323
|
-
cloned.first.
|
323
|
+
expect(cloned.first).to_not eq(post)
|
324
324
|
end
|
325
325
|
|
326
326
|
it "does not retain the last id" do
|
327
|
-
cloned.last.
|
327
|
+
expect(cloned.last).to_not eq(post_two)
|
328
328
|
end
|
329
329
|
end
|
330
330
|
|
@@ -349,11 +349,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
349
349
|
end
|
350
350
|
|
351
351
|
it "deletes the document from the enumerable" do
|
352
|
-
enumerable._loaded.
|
352
|
+
expect(enumerable._loaded).to be_empty
|
353
353
|
end
|
354
354
|
|
355
355
|
it "returns the document" do
|
356
|
-
deleted.
|
356
|
+
expect(deleted).to eq(post)
|
357
357
|
end
|
358
358
|
end
|
359
359
|
|
@@ -380,11 +380,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
380
380
|
end
|
381
381
|
|
382
382
|
it "removes the document from the added docs" do
|
383
|
-
enumerable._added.
|
383
|
+
expect(enumerable._added).to be_empty
|
384
384
|
end
|
385
385
|
|
386
386
|
it "returns the document" do
|
387
|
-
deleted.
|
387
|
+
expect(deleted).to eq(post)
|
388
388
|
end
|
389
389
|
end
|
390
390
|
|
@@ -407,11 +407,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
407
407
|
end
|
408
408
|
|
409
409
|
it "does not load the document" do
|
410
|
-
enumerable._loaded.
|
410
|
+
expect(enumerable._loaded).to be_empty
|
411
411
|
end
|
412
412
|
|
413
413
|
it "returns the document" do
|
414
|
-
deleted.
|
414
|
+
expect(deleted).to eq(post)
|
415
415
|
end
|
416
416
|
end
|
417
417
|
|
@@ -431,12 +431,12 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
431
431
|
|
432
432
|
let!(:deleted) do
|
433
433
|
enumerable.delete(Post.new) do |doc|
|
434
|
-
doc.
|
434
|
+
expect(doc).to be_nil
|
435
435
|
end
|
436
436
|
end
|
437
437
|
|
438
438
|
it "returns nil" do
|
439
|
-
deleted.
|
439
|
+
expect(deleted).to be_nil
|
440
440
|
end
|
441
441
|
end
|
442
442
|
end
|
@@ -462,11 +462,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
462
462
|
end
|
463
463
|
|
464
464
|
it "deletes the document from the enumerable" do
|
465
|
-
enumerable._loaded.
|
465
|
+
expect(enumerable._loaded).to be_empty
|
466
466
|
end
|
467
467
|
|
468
468
|
it "returns the remaining docs" do
|
469
|
-
deleted.
|
469
|
+
expect(deleted).to be_empty
|
470
470
|
end
|
471
471
|
end
|
472
472
|
|
@@ -493,11 +493,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
493
493
|
end
|
494
494
|
|
495
495
|
it "removes the document from the added docs" do
|
496
|
-
enumerable._added.
|
496
|
+
expect(enumerable._added).to be_empty
|
497
497
|
end
|
498
498
|
|
499
499
|
it "returns the remaining docs" do
|
500
|
-
deleted.
|
500
|
+
expect(deleted).to be_empty
|
501
501
|
end
|
502
502
|
end
|
503
503
|
|
@@ -520,11 +520,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
520
520
|
end
|
521
521
|
|
522
522
|
it "does not load the document" do
|
523
|
-
enumerable._loaded.
|
523
|
+
expect(enumerable._loaded).to be_empty
|
524
524
|
end
|
525
525
|
|
526
526
|
it "returns the remaining docs" do
|
527
|
-
deleted.
|
527
|
+
expect(deleted).to be_empty
|
528
528
|
end
|
529
529
|
end
|
530
530
|
|
@@ -547,7 +547,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
547
547
|
end
|
548
548
|
|
549
549
|
it "returns the remaining docs" do
|
550
|
-
deleted.
|
550
|
+
expect(deleted).to eq([ post ])
|
551
551
|
end
|
552
552
|
end
|
553
553
|
end
|
@@ -577,7 +577,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
577
577
|
end
|
578
578
|
|
579
579
|
it "sets the value on the instance" do
|
580
|
-
enumerable.detect{ |post| post.title = "test" }.rating.
|
580
|
+
expect(enumerable.detect{ |post| post.title = "test" }.rating).to eq(10)
|
581
581
|
end
|
582
582
|
end
|
583
583
|
end
|
@@ -604,16 +604,16 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
604
604
|
|
605
605
|
let!(:iterated) do
|
606
606
|
enumerable.each do |doc|
|
607
|
-
doc.
|
607
|
+
expect(doc).to be_a(Post)
|
608
608
|
end
|
609
609
|
end
|
610
610
|
|
611
611
|
it "loads each document" do
|
612
|
-
enumerable._loaded.
|
612
|
+
expect(enumerable._loaded).to eq({ post.id => post })
|
613
613
|
end
|
614
614
|
|
615
615
|
it "becomes loaded" do
|
616
|
-
enumerable.
|
616
|
+
expect(enumerable).to be__loaded
|
617
617
|
end
|
618
618
|
end
|
619
619
|
|
@@ -625,16 +625,16 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
625
625
|
|
626
626
|
let!(:iterated) do
|
627
627
|
enumerable.each do |doc|
|
628
|
-
doc.
|
628
|
+
expect(doc).to be_a(Post)
|
629
629
|
end
|
630
630
|
end
|
631
631
|
|
632
632
|
it "does not alter the loaded docs" do
|
633
|
-
enumerable._loaded.
|
633
|
+
expect(enumerable._loaded).to eq({ post.id => post })
|
634
634
|
end
|
635
635
|
|
636
636
|
it "stays loaded" do
|
637
|
-
enumerable.
|
637
|
+
expect(enumerable).to be__loaded
|
638
638
|
end
|
639
639
|
end
|
640
640
|
|
@@ -660,20 +660,20 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
660
660
|
|
661
661
|
let!(:iterated) do
|
662
662
|
enumerable.each do |doc|
|
663
|
-
doc.
|
663
|
+
expect(doc).to be_a(Post)
|
664
664
|
end
|
665
665
|
end
|
666
666
|
|
667
667
|
it "adds the unloaded to the loaded docs" do
|
668
|
-
enumerable._loaded.
|
668
|
+
expect(enumerable._loaded).to eq({ post.id => post })
|
669
669
|
end
|
670
670
|
|
671
671
|
it "keeps the appended in the added docs" do
|
672
|
-
enumerable._added.
|
672
|
+
expect(enumerable._added).to eq({ post_two.id => post_two })
|
673
673
|
end
|
674
674
|
|
675
675
|
it "stays loaded" do
|
676
|
-
enumerable.
|
676
|
+
expect(enumerable).to be__loaded
|
677
677
|
end
|
678
678
|
end
|
679
679
|
|
@@ -685,16 +685,16 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
685
685
|
|
686
686
|
let!(:iterated) do
|
687
687
|
enumerable.each do |doc|
|
688
|
-
doc.
|
688
|
+
expect(doc).to be_a(Post)
|
689
689
|
end
|
690
690
|
end
|
691
691
|
|
692
692
|
it "adds the persisted added doc to the loaded" do
|
693
|
-
enumerable._loaded.
|
693
|
+
expect(enumerable._loaded).to eq({ post.id => post })
|
694
694
|
end
|
695
695
|
|
696
696
|
it "stays loaded" do
|
697
|
-
enumerable.
|
697
|
+
expect(enumerable).to be__loaded
|
698
698
|
end
|
699
699
|
end
|
700
700
|
end
|
@@ -710,7 +710,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
710
710
|
end
|
711
711
|
|
712
712
|
it "returns an enumerator" do
|
713
|
-
enumerable.each.class.include?(Enumerable).
|
713
|
+
expect(enumerable.each.class.include?(Enumerable)).to be true
|
714
714
|
end
|
715
715
|
|
716
716
|
end
|
@@ -745,7 +745,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
745
745
|
end
|
746
746
|
|
747
747
|
it "yields to the in memory documents first" do
|
748
|
-
entries.first.
|
748
|
+
expect(entries.first).to equal(post)
|
749
749
|
end
|
750
750
|
end
|
751
751
|
end
|
@@ -779,11 +779,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
779
779
|
end
|
780
780
|
|
781
781
|
it "returns the first unloaded doc" do
|
782
|
-
first.
|
782
|
+
expect(first).to eq(post)
|
783
783
|
end
|
784
784
|
|
785
785
|
it "does not load the enumerable" do
|
786
|
-
enumerable.
|
786
|
+
expect(enumerable).to_not be__loaded
|
787
787
|
end
|
788
788
|
|
789
789
|
it "receives query only once" do
|
@@ -813,11 +813,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
813
813
|
context "when a perviously persisted unloaded doc exists" do
|
814
814
|
|
815
815
|
it "returns the first added doc" do
|
816
|
-
first.
|
816
|
+
expect(first).to eq(post)
|
817
817
|
end
|
818
818
|
|
819
819
|
it "does not load the enumerable" do
|
820
|
-
enumerable.
|
820
|
+
expect(enumerable).to_not be__loaded
|
821
821
|
end
|
822
822
|
end
|
823
823
|
end
|
@@ -838,11 +838,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
838
838
|
end
|
839
839
|
|
840
840
|
it "returns the first loaded doc" do
|
841
|
-
first.
|
841
|
+
expect(first).to eq(post)
|
842
842
|
end
|
843
843
|
|
844
844
|
it "does not load the enumerable" do
|
845
|
-
enumerable.
|
845
|
+
expect(enumerable).to_not be__loaded
|
846
846
|
end
|
847
847
|
end
|
848
848
|
|
@@ -853,11 +853,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
853
853
|
end
|
854
854
|
|
855
855
|
it "returns nil" do
|
856
|
-
first.
|
856
|
+
expect(first).to be_nil
|
857
857
|
end
|
858
858
|
|
859
859
|
it "does not load the enumerable" do
|
860
|
-
enumerable.
|
860
|
+
expect(enumerable).to_not be__loaded
|
861
861
|
end
|
862
862
|
end
|
863
863
|
end
|
@@ -879,7 +879,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
879
879
|
end
|
880
880
|
|
881
881
|
it "returns the first loaded doc" do
|
882
|
-
first.
|
882
|
+
expect(first).to eq(post)
|
883
883
|
end
|
884
884
|
end
|
885
885
|
|
@@ -902,7 +902,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
902
902
|
end
|
903
903
|
|
904
904
|
it "returns the first added doc" do
|
905
|
-
first.
|
905
|
+
expect(first).to eq(post)
|
906
906
|
end
|
907
907
|
end
|
908
908
|
|
@@ -917,7 +917,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
917
917
|
end
|
918
918
|
|
919
919
|
it "returns nil" do
|
920
|
-
first.
|
920
|
+
expect(first).to be_nil
|
921
921
|
end
|
922
922
|
end
|
923
923
|
end
|
@@ -950,15 +950,15 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
950
950
|
end
|
951
951
|
|
952
952
|
it "returns true" do
|
953
|
-
included.
|
953
|
+
expect(included).to be true
|
954
954
|
end
|
955
955
|
|
956
956
|
it "retains the correct length" do
|
957
|
-
enumerable.length.
|
957
|
+
expect(enumerable.length).to eq(2)
|
958
958
|
end
|
959
959
|
|
960
960
|
it "retains the correct length when calling to_a" do
|
961
|
-
enumerable.to_a.length.
|
961
|
+
expect(enumerable.to_a.length).to eq(2)
|
962
962
|
end
|
963
963
|
end
|
964
964
|
|
@@ -981,7 +981,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
981
981
|
end
|
982
982
|
|
983
983
|
it "returns true" do
|
984
|
-
included.
|
984
|
+
expect(included).to be true
|
985
985
|
end
|
986
986
|
end
|
987
987
|
end
|
@@ -1001,15 +1001,15 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1001
1001
|
end
|
1002
1002
|
|
1003
1003
|
it "returns true" do
|
1004
|
-
included.
|
1004
|
+
expect(included).to be true
|
1005
1005
|
end
|
1006
1006
|
|
1007
1007
|
it "retains the correct length" do
|
1008
|
-
enumerable.length.
|
1008
|
+
expect(enumerable.length).to eq(2)
|
1009
1009
|
end
|
1010
1010
|
|
1011
1011
|
it "retains the correct length when calling to_a" do
|
1012
|
-
enumerable.to_a.length.
|
1012
|
+
expect(enumerable.to_a.length).to eq(2)
|
1013
1013
|
end
|
1014
1014
|
|
1015
1015
|
context "when iterating over the relation a second time" do
|
@@ -1019,11 +1019,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1019
1019
|
end
|
1020
1020
|
|
1021
1021
|
it "retains the correct length" do
|
1022
|
-
enumerable.length.
|
1022
|
+
expect(enumerable.length).to eq(2)
|
1023
1023
|
end
|
1024
1024
|
|
1025
1025
|
it "retains the correct length when calling to_a" do
|
1026
|
-
enumerable.to_a.length.
|
1026
|
+
expect(enumerable.to_a.length).to eq(2)
|
1027
1027
|
end
|
1028
1028
|
end
|
1029
1029
|
end
|
@@ -1046,11 +1046,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1046
1046
|
end
|
1047
1047
|
|
1048
1048
|
it "sets the criteria" do
|
1049
|
-
enumerable._unloaded.
|
1049
|
+
expect(enumerable._unloaded).to eq(criteria)
|
1050
1050
|
end
|
1051
1051
|
|
1052
1052
|
it "is not loaded" do
|
1053
|
-
enumerable.
|
1053
|
+
expect(enumerable).to_not be__loaded
|
1054
1054
|
end
|
1055
1055
|
end
|
1056
1056
|
|
@@ -1065,11 +1065,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1065
1065
|
end
|
1066
1066
|
|
1067
1067
|
it "does not set a criteria" do
|
1068
|
-
enumerable._unloaded.
|
1068
|
+
expect(enumerable._unloaded).to be_nil
|
1069
1069
|
end
|
1070
1070
|
|
1071
1071
|
it "is loaded" do
|
1072
|
-
enumerable.
|
1072
|
+
expect(enumerable).to be__loaded
|
1073
1073
|
end
|
1074
1074
|
end
|
1075
1075
|
end
|
@@ -1103,7 +1103,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1103
1103
|
end
|
1104
1104
|
|
1105
1105
|
it "returns the loaded and added docs" do
|
1106
|
-
in_memory.
|
1106
|
+
expect(in_memory).to eq([ post, post_two ])
|
1107
1107
|
end
|
1108
1108
|
end
|
1109
1109
|
|
@@ -1130,7 +1130,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1130
1130
|
end
|
1131
1131
|
|
1132
1132
|
it "returns the added docs" do
|
1133
|
-
in_memory.
|
1133
|
+
expect(in_memory).to eq([ post_two ])
|
1134
1134
|
end
|
1135
1135
|
end
|
1136
1136
|
|
@@ -1150,7 +1150,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1150
1150
|
|
1151
1151
|
it "yields to each in memory document" do
|
1152
1152
|
enumerable.in_memory do |doc|
|
1153
|
-
doc.
|
1153
|
+
expect(doc).to eq(post_two)
|
1154
1154
|
end
|
1155
1155
|
end
|
1156
1156
|
end
|
@@ -1165,14 +1165,14 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1165
1165
|
context "when checking against enumerable" do
|
1166
1166
|
|
1167
1167
|
it "returns true" do
|
1168
|
-
enumerable.is_a?(::Enumerable).
|
1168
|
+
expect(enumerable.is_a?(::Enumerable)).to be true
|
1169
1169
|
end
|
1170
1170
|
end
|
1171
1171
|
|
1172
1172
|
context "when checking against array" do
|
1173
1173
|
|
1174
1174
|
it "returns true" do
|
1175
|
-
enumerable.is_a?(Array).
|
1175
|
+
expect(enumerable.is_a?(Array)).to be true
|
1176
1176
|
end
|
1177
1177
|
end
|
1178
1178
|
end
|
@@ -1204,11 +1204,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1204
1204
|
end
|
1205
1205
|
|
1206
1206
|
it "returns the last unloaded doc" do
|
1207
|
-
last.
|
1207
|
+
expect(last).to eq(post)
|
1208
1208
|
end
|
1209
1209
|
|
1210
1210
|
it "does not load the enumerable" do
|
1211
|
-
enumerable.
|
1211
|
+
expect(enumerable).to_not be__loaded
|
1212
1212
|
end
|
1213
1213
|
|
1214
1214
|
it "receives query only once" do
|
@@ -1232,11 +1232,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1232
1232
|
end
|
1233
1233
|
|
1234
1234
|
it "returns the last unloaded doc" do
|
1235
|
-
last.
|
1235
|
+
expect(last).to eq(post)
|
1236
1236
|
end
|
1237
1237
|
|
1238
1238
|
it "does not load the enumerable" do
|
1239
|
-
enumerable.
|
1239
|
+
expect(enumerable).to_not be__loaded
|
1240
1240
|
end
|
1241
1241
|
end
|
1242
1242
|
|
@@ -1247,11 +1247,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1247
1247
|
end
|
1248
1248
|
|
1249
1249
|
it "returns nil" do
|
1250
|
-
last.
|
1250
|
+
expect(last).to be_nil
|
1251
1251
|
end
|
1252
1252
|
|
1253
1253
|
it "does not load the enumerable" do
|
1254
|
-
enumerable.
|
1254
|
+
expect(enumerable).to_not be__loaded
|
1255
1255
|
end
|
1256
1256
|
end
|
1257
1257
|
|
@@ -1272,7 +1272,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1272
1272
|
context "when accessing from a reloaded child" do
|
1273
1273
|
|
1274
1274
|
it "returns the last document" do
|
1275
|
-
post_one.reload.person.posts.last.
|
1275
|
+
expect(post_one.reload.person.posts.last).to eq(post_two)
|
1276
1276
|
end
|
1277
1277
|
end
|
1278
1278
|
end
|
@@ -1295,7 +1295,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1295
1295
|
end
|
1296
1296
|
|
1297
1297
|
it "returns the last loaded doc" do
|
1298
|
-
last.
|
1298
|
+
expect(last).to eq(post)
|
1299
1299
|
end
|
1300
1300
|
end
|
1301
1301
|
|
@@ -1318,7 +1318,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1318
1318
|
end
|
1319
1319
|
|
1320
1320
|
it "returns the last added doc" do
|
1321
|
-
last.
|
1321
|
+
expect(last).to eq(post)
|
1322
1322
|
end
|
1323
1323
|
end
|
1324
1324
|
|
@@ -1333,7 +1333,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1333
1333
|
end
|
1334
1334
|
|
1335
1335
|
it "returns nil" do
|
1336
|
-
last.
|
1336
|
+
expect(last).to be_nil
|
1337
1337
|
end
|
1338
1338
|
end
|
1339
1339
|
end
|
@@ -1348,14 +1348,14 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1348
1348
|
context "when checking against enumerable" do
|
1349
1349
|
|
1350
1350
|
it "returns true" do
|
1351
|
-
enumerable.kind_of?(::Enumerable).
|
1351
|
+
expect(enumerable.kind_of?(::Enumerable)).to be true
|
1352
1352
|
end
|
1353
1353
|
end
|
1354
1354
|
|
1355
1355
|
context "when checking against array" do
|
1356
1356
|
|
1357
1357
|
it "returns true" do
|
1358
|
-
enumerable.kind_of?(Array).
|
1358
|
+
expect(enumerable.kind_of?(Array)).to be true
|
1359
1359
|
end
|
1360
1360
|
end
|
1361
1361
|
end
|
@@ -1383,15 +1383,15 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1383
1383
|
end
|
1384
1384
|
|
1385
1385
|
it "loads all the unloaded documents" do
|
1386
|
-
enumerable._loaded.
|
1386
|
+
expect(enumerable._loaded).to eq({ post.id => post })
|
1387
1387
|
end
|
1388
1388
|
|
1389
|
-
it "returns
|
1390
|
-
loaded.
|
1389
|
+
it "returns the object" do
|
1390
|
+
expect(loaded).to eq([post])
|
1391
1391
|
end
|
1392
1392
|
|
1393
1393
|
it "sets loaded to true" do
|
1394
|
-
enumerable.
|
1394
|
+
expect(enumerable).to be__loaded
|
1395
1395
|
end
|
1396
1396
|
end
|
1397
1397
|
|
@@ -1422,15 +1422,15 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1422
1422
|
end
|
1423
1423
|
|
1424
1424
|
it "is not loaded" do
|
1425
|
-
enumerable.
|
1425
|
+
expect(enumerable).to_not be__loaded
|
1426
1426
|
end
|
1427
1427
|
|
1428
1428
|
it "clears out the loaded docs" do
|
1429
|
-
enumerable._loaded.
|
1429
|
+
expect(enumerable._loaded).to be_empty
|
1430
1430
|
end
|
1431
1431
|
|
1432
1432
|
it "clears out the added docs" do
|
1433
|
-
enumerable._added.
|
1433
|
+
expect(enumerable._added).to be_empty
|
1434
1434
|
end
|
1435
1435
|
end
|
1436
1436
|
|
@@ -1445,7 +1445,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1445
1445
|
[].methods.each do |method|
|
1446
1446
|
|
1447
1447
|
it "returns true for #{method}" do
|
1448
|
-
enumerable.
|
1448
|
+
expect(enumerable).to respond_to(method)
|
1449
1449
|
end
|
1450
1450
|
end
|
1451
1451
|
end
|
@@ -1480,7 +1480,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1480
1480
|
end
|
1481
1481
|
|
1482
1482
|
it "includes the number of all added documents" do
|
1483
|
-
enumerable.size.
|
1483
|
+
expect(enumerable.size).to eq(1)
|
1484
1484
|
end
|
1485
1485
|
end
|
1486
1486
|
end
|
@@ -1505,11 +1505,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1505
1505
|
end
|
1506
1506
|
|
1507
1507
|
it "returns the loaded size plus added size" do
|
1508
|
-
size.
|
1508
|
+
expect(size).to eq(2)
|
1509
1509
|
end
|
1510
1510
|
|
1511
1511
|
it "matches the size of the loaded enumerable" do
|
1512
|
-
size.
|
1512
|
+
expect(size).to eq(enumerable.to_a.size)
|
1513
1513
|
end
|
1514
1514
|
end
|
1515
1515
|
|
@@ -1534,7 +1534,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1534
1534
|
end
|
1535
1535
|
|
1536
1536
|
it "returns the unloaded count plus added new size" do
|
1537
|
-
size.
|
1537
|
+
expect(size).to eq(2)
|
1538
1538
|
end
|
1539
1539
|
end
|
1540
1540
|
|
@@ -1553,7 +1553,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1553
1553
|
end
|
1554
1554
|
|
1555
1555
|
it "returns the unloaded count plus added new size" do
|
1556
|
-
size.
|
1556
|
+
expect(size).to eq(2)
|
1557
1557
|
end
|
1558
1558
|
end
|
1559
1559
|
end
|
@@ -1586,7 +1586,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1586
1586
|
end
|
1587
1587
|
|
1588
1588
|
it "serializes the enumerable" do
|
1589
|
-
json.
|
1589
|
+
expect(json).to include(post.title)
|
1590
1590
|
end
|
1591
1591
|
end
|
1592
1592
|
|
@@ -1609,7 +1609,7 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1609
1609
|
end
|
1610
1610
|
|
1611
1611
|
it "serializes the enumerable" do
|
1612
|
-
json.
|
1612
|
+
expect(json).to_not include(post.title)
|
1613
1613
|
end
|
1614
1614
|
end
|
1615
1615
|
|
@@ -1640,8 +1640,8 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1640
1640
|
end
|
1641
1641
|
|
1642
1642
|
it "serializes the enumerable" do
|
1643
|
-
json.size.
|
1644
|
-
json[0]['title'].
|
1643
|
+
expect(json.size).to eq(1)
|
1644
|
+
expect(json[0]['title']).to eq(post.title)
|
1645
1645
|
end
|
1646
1646
|
end
|
1647
1647
|
|
@@ -1664,11 +1664,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1664
1664
|
end
|
1665
1665
|
|
1666
1666
|
it "serializes the enumerable" do
|
1667
|
-
json.size.
|
1667
|
+
expect(json.size).to eq(1)
|
1668
1668
|
end
|
1669
1669
|
|
1670
1670
|
it "includes the proper fields" do
|
1671
|
-
json[0].keys.
|
1671
|
+
expect(json[0].keys).to_not include("title")
|
1672
1672
|
end
|
1673
1673
|
end
|
1674
1674
|
|
@@ -1700,11 +1700,11 @@ describe Mongoid::Relations::Targets::Enumerable do
|
|
1700
1700
|
end
|
1701
1701
|
|
1702
1702
|
it "returns the unique documents" do
|
1703
|
-
uniq.
|
1703
|
+
expect(uniq).to eq([ post ])
|
1704
1704
|
end
|
1705
1705
|
|
1706
1706
|
it "sets loaded to true" do
|
1707
|
-
enumerable.
|
1707
|
+
expect(enumerable).to be__loaded
|
1708
1708
|
end
|
1709
1709
|
end
|
1710
1710
|
end
|