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
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Mongoid::
|
3
|
+
describe Mongoid::Validatable::PresenceValidator do
|
4
4
|
|
5
5
|
describe "#validate_each" do
|
6
6
|
|
@@ -21,7 +21,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "adds no errors" do
|
24
|
-
product.errors[:brand_name].
|
24
|
+
expect(product.errors[:brand_name]).to be_empty
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -32,7 +32,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "adds errors" do
|
35
|
-
product.errors[:brand_name].
|
35
|
+
expect(product.errors[:brand_name]).to eq(["can't be blank"])
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -43,7 +43,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "adds errors" do
|
46
|
-
product.errors[:brand_name].
|
46
|
+
expect(product.errors[:brand_name]).to eq(["can't be blank"])
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -57,7 +57,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "adds no errors" do
|
60
|
-
product.errors[:name].
|
60
|
+
expect(product.errors[:name]).to be_empty
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -68,7 +68,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "adds errors" do
|
71
|
-
product.errors[:name].
|
71
|
+
expect(product.errors[:name]).to eq(["can't be blank"])
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -79,7 +79,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "adds errors" do
|
82
|
-
product.errors[:name].
|
82
|
+
expect(product.errors[:name]).to eq(["can't be blank in en"])
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
@@ -90,7 +90,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "adds errors" do
|
93
|
-
product.errors[:name].
|
93
|
+
expect(product.errors[:name]).to eq(["can't be blank in en"])
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -105,7 +105,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "adds errors" do
|
108
|
-
product.errors[:name].
|
108
|
+
expect(product.errors[:name]).to eq(["can't be blank in de"])
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -120,7 +120,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it "adds errors" do
|
123
|
-
product.errors[:name].
|
123
|
+
expect(product.errors[:name]).to eq(["can't be blank in en", "can't be blank in de"])
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -212,12 +212,10 @@ describe Mongoid::Validations::PresenceValidator do
|
|
212
212
|
context "when the relation is a has one" do
|
213
213
|
|
214
214
|
before do
|
215
|
-
Person.autosaved_relations.delete_one(:game)
|
216
215
|
Person.validates :game, presence: true
|
217
216
|
end
|
218
217
|
|
219
218
|
after do
|
220
|
-
Person.autosaved_relations.clear
|
221
219
|
Person.reset_callbacks(:save)
|
222
220
|
Person.reset_callbacks(:validate)
|
223
221
|
end
|
@@ -241,7 +239,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
241
239
|
end
|
242
240
|
|
243
241
|
it "saves the relation" do
|
244
|
-
game.reload.
|
242
|
+
expect(game.reload).to eq(game)
|
245
243
|
end
|
246
244
|
end
|
247
245
|
end
|
@@ -260,11 +258,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
260
258
|
end
|
261
259
|
|
262
260
|
it "does not change autosave on the relation" do
|
263
|
-
Person.relations["game"][:autosave].
|
264
|
-
end
|
265
|
-
|
266
|
-
it "does not add any autosaved relations" do
|
267
|
-
Person.autosaved_relations.should be_empty
|
261
|
+
expect(Person.relations["game"][:autosave]).to be false
|
268
262
|
end
|
269
263
|
|
270
264
|
context "when the relation is new" do
|
@@ -316,7 +310,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
316
310
|
end
|
317
311
|
|
318
312
|
it "is not valid" do
|
319
|
-
line_item.
|
313
|
+
expect(line_item).to_not be_valid
|
320
314
|
end
|
321
315
|
end
|
322
316
|
end
|
@@ -329,7 +323,6 @@ describe Mongoid::Validations::PresenceValidator do
|
|
329
323
|
end
|
330
324
|
|
331
325
|
after do
|
332
|
-
Person.autosaved_relations.clear
|
333
326
|
Person.reset_callbacks(:save)
|
334
327
|
Person.reset_callbacks(:validate)
|
335
328
|
end
|
@@ -351,14 +344,14 @@ describe Mongoid::Validations::PresenceValidator do
|
|
351
344
|
end
|
352
345
|
|
353
346
|
it "is valid" do
|
354
|
-
loaded.
|
347
|
+
expect(loaded).to be_valid
|
355
348
|
end
|
356
349
|
end
|
357
350
|
|
358
351
|
context "when the relation is in memory" do
|
359
352
|
|
360
353
|
it "is valid" do
|
361
|
-
person.
|
354
|
+
expect(person).to be_valid
|
362
355
|
end
|
363
356
|
end
|
364
357
|
end
|
@@ -378,12 +371,12 @@ describe Mongoid::Validations::PresenceValidator do
|
|
378
371
|
end
|
379
372
|
|
380
373
|
it "is not a valid document" do
|
381
|
-
product.
|
374
|
+
expect(product).to_not be_valid
|
382
375
|
end
|
383
376
|
|
384
377
|
it "includes the proper errors" do
|
385
378
|
product.valid?
|
386
|
-
product.errors[:name].
|
379
|
+
expect(product.errors[:name]).to_not be_empty
|
387
380
|
end
|
388
381
|
end
|
389
382
|
|
@@ -398,12 +391,12 @@ describe Mongoid::Validations::PresenceValidator do
|
|
398
391
|
end
|
399
392
|
|
400
393
|
it "is not a valid document" do
|
401
|
-
product.
|
394
|
+
expect(product).to_not be_valid
|
402
395
|
end
|
403
396
|
|
404
397
|
it "includes the proper errors" do
|
405
398
|
product.valid?
|
406
|
-
product.errors[:name].
|
399
|
+
expect(product.errors[:name]).to_not be_empty
|
407
400
|
end
|
408
401
|
end
|
409
402
|
|
@@ -418,12 +411,12 @@ describe Mongoid::Validations::PresenceValidator do
|
|
418
411
|
end
|
419
412
|
|
420
413
|
it "is not a valid document" do
|
421
|
-
product.
|
414
|
+
expect(product).to_not be_valid
|
422
415
|
end
|
423
416
|
|
424
417
|
it "includes the proper errors" do
|
425
418
|
product.valid?
|
426
|
-
product.errors[:name].
|
419
|
+
expect(product.errors[:name]).to_not be_empty
|
427
420
|
end
|
428
421
|
end
|
429
422
|
|
@@ -438,12 +431,12 @@ describe Mongoid::Validations::PresenceValidator do
|
|
438
431
|
end
|
439
432
|
|
440
433
|
it "is not a valid document" do
|
441
|
-
product.
|
434
|
+
expect(product).to_not be_valid
|
442
435
|
end
|
443
436
|
|
444
437
|
it "includes the proper errors" do
|
445
438
|
product.valid?
|
446
|
-
product.errors[:name].
|
439
|
+
expect(product.errors[:name]).to_not be_empty
|
447
440
|
end
|
448
441
|
end
|
449
442
|
|
@@ -458,7 +451,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
458
451
|
end
|
459
452
|
|
460
453
|
it "is a valid document" do
|
461
|
-
product.
|
454
|
+
expect(product).to be_valid
|
462
455
|
end
|
463
456
|
end
|
464
457
|
end
|
@@ -483,7 +476,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
483
476
|
end
|
484
477
|
|
485
478
|
it "persists the changes" do
|
486
|
-
reloaded.products.
|
479
|
+
expect(reloaded.products).to eq(updated_products)
|
487
480
|
end
|
488
481
|
end
|
489
482
|
|
@@ -506,11 +499,11 @@ describe Mongoid::Validations::PresenceValidator do
|
|
506
499
|
end
|
507
500
|
|
508
501
|
it "does not destroy the models change list" do
|
509
|
-
manufacturer.changes.
|
502
|
+
expect(manufacturer.changes).to_not be_empty
|
510
503
|
end
|
511
504
|
|
512
505
|
it "maintains the list of changes" do
|
513
|
-
manufacturer.changes.
|
506
|
+
expect(manufacturer.changes).to eq({
|
514
507
|
"products" => [
|
515
508
|
[ "Laptop", "Tablet" ],
|
516
509
|
[ "Laptop", "Tablet", "Smartphone", "Desktop" ]
|
@@ -529,7 +522,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
529
522
|
context "when the value is false" do
|
530
523
|
|
531
524
|
it "is a valid document" do
|
532
|
-
template.
|
525
|
+
expect(template).to be_valid
|
533
526
|
end
|
534
527
|
end
|
535
528
|
|
@@ -540,7 +533,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
540
533
|
end
|
541
534
|
|
542
535
|
it "is a valid document" do
|
543
|
-
template.
|
536
|
+
expect(template).to be_valid
|
544
537
|
end
|
545
538
|
end
|
546
539
|
end
|
@@ -556,7 +549,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
556
549
|
end
|
557
550
|
|
558
551
|
it "adds the validation only to the instance" do
|
559
|
-
validators.
|
552
|
+
expect(validators).to eq([ described_class ])
|
560
553
|
end
|
561
554
|
end
|
562
555
|
|
@@ -584,7 +577,7 @@ describe Mongoid::Validations::PresenceValidator do
|
|
584
577
|
end
|
585
578
|
|
586
579
|
it "adds the errors to the document" do
|
587
|
-
person.errors[:aliases].
|
580
|
+
expect(person.errors[:aliases]).to_not be_empty
|
588
581
|
end
|
589
582
|
end
|
590
583
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Mongoid::
|
3
|
+
describe Mongoid::Validatable::UniquenessValidator do
|
4
4
|
|
5
5
|
describe "#valid?" do
|
6
6
|
|
@@ -29,17 +29,17 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it "performs the validation on the correct collection" do
|
32
|
-
websters.
|
32
|
+
expect(websters).to_not be_valid
|
33
33
|
end
|
34
34
|
|
35
35
|
it "adds the uniqueness error" do
|
36
36
|
websters.valid?
|
37
|
-
websters.errors[:name].
|
37
|
+
expect(websters.errors[:name]).to_not be_nil
|
38
38
|
end
|
39
39
|
|
40
40
|
it "clears the persistence options in the thread local" do
|
41
41
|
websters.valid?
|
42
|
-
Dictionary.persistence_options.
|
42
|
+
expect(Dictionary.persistence_options).to be_nil
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -50,65 +50,8 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "performs the validation on the correct collection" do
|
53
|
-
oxford.
|
53
|
+
expect(oxford).to be_valid
|
54
54
|
end
|
55
|
-
|
56
|
-
it "does not clear the persistence options in the thread local" do
|
57
|
-
oxford.valid?
|
58
|
-
Dictionary.persistence_options.should_not be_nil
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "when the document is paranoid" do
|
65
|
-
|
66
|
-
before do
|
67
|
-
ParanoidPost.validates_uniqueness_of :title
|
68
|
-
end
|
69
|
-
|
70
|
-
after do
|
71
|
-
ParanoidPost.reset_callbacks(:validate)
|
72
|
-
end
|
73
|
-
|
74
|
-
let!(:post) do
|
75
|
-
ParanoidPost.create(title: "testing")
|
76
|
-
end
|
77
|
-
|
78
|
-
context "when the field is unique" do
|
79
|
-
|
80
|
-
let(:new_post) do
|
81
|
-
ParanoidPost.new(title: "test")
|
82
|
-
end
|
83
|
-
|
84
|
-
it "returns true" do
|
85
|
-
new_post.should be_valid
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "when the field is unique for non soft deleted docs" do
|
90
|
-
|
91
|
-
before do
|
92
|
-
post.delete
|
93
|
-
end
|
94
|
-
|
95
|
-
let(:new_post) do
|
96
|
-
ParanoidPost.new(title: "testing")
|
97
|
-
end
|
98
|
-
|
99
|
-
it "returns true" do
|
100
|
-
new_post.should be_valid
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context "when the field is not unique" do
|
105
|
-
|
106
|
-
let(:new_post) do
|
107
|
-
ParanoidPost.new(title: "testing")
|
108
|
-
end
|
109
|
-
|
110
|
-
it "returns false" do
|
111
|
-
new_post.should_not be_valid
|
112
55
|
end
|
113
56
|
end
|
114
57
|
end
|
@@ -136,7 +79,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
136
79
|
end
|
137
80
|
|
138
81
|
it "returns true" do
|
139
|
-
word.
|
82
|
+
expect(word).to be_valid
|
140
83
|
end
|
141
84
|
end
|
142
85
|
end
|
@@ -209,7 +152,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
209
152
|
context "when single localization" do
|
210
153
|
|
211
154
|
before do
|
212
|
-
Dictionary.
|
155
|
+
Dictionary.create(description: "english")
|
213
156
|
end
|
214
157
|
|
215
158
|
let(:dictionary) do
|
@@ -224,7 +167,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
224
167
|
context "when multiple localizations" do
|
225
168
|
|
226
169
|
before do
|
227
|
-
Dictionary.
|
170
|
+
Dictionary.
|
228
171
|
create(description_translations: { "en" => "english", "de" => "german" })
|
229
172
|
end
|
230
173
|
|
@@ -245,7 +188,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
245
188
|
context "when single localization" do
|
246
189
|
|
247
190
|
before do
|
248
|
-
Dictionary.
|
191
|
+
Dictionary.create(description: "english")
|
249
192
|
end
|
250
193
|
|
251
194
|
let(:dictionary) do
|
@@ -265,7 +208,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
265
208
|
context "when multiple localizations" do
|
266
209
|
|
267
210
|
before do
|
268
|
-
Dictionary.
|
211
|
+
Dictionary.
|
269
212
|
create(description_translations: { "en" => "english", "de" => "german" })
|
270
213
|
end
|
271
214
|
|
@@ -301,7 +244,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
301
244
|
context "when there are no special characters" do
|
302
245
|
|
303
246
|
before do
|
304
|
-
Dictionary.
|
247
|
+
Dictionary.create(description: "english")
|
305
248
|
end
|
306
249
|
|
307
250
|
let(:dictionary) do
|
@@ -316,7 +259,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
316
259
|
context "when special characters exist" do
|
317
260
|
|
318
261
|
before do
|
319
|
-
Dictionary.
|
262
|
+
Dictionary.create(description: "english")
|
320
263
|
end
|
321
264
|
|
322
265
|
let(:dictionary) do
|
@@ -336,7 +279,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
336
279
|
context "when signle localization" do
|
337
280
|
|
338
281
|
before do
|
339
|
-
Dictionary.
|
282
|
+
Dictionary.create(description: "english")
|
340
283
|
end
|
341
284
|
|
342
285
|
let(:dictionary) do
|
@@ -356,7 +299,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
356
299
|
context "when multiple localizations" do
|
357
300
|
|
358
301
|
before do
|
359
|
-
Dictionary.
|
302
|
+
Dictionary.
|
360
303
|
create(description_translations: { "en" => "english", "de" => "german" })
|
361
304
|
end
|
362
305
|
|
@@ -378,7 +321,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
378
321
|
context "when the document is the match in the database" do
|
379
322
|
|
380
323
|
let!(:dictionary) do
|
381
|
-
Dictionary.
|
324
|
+
Dictionary.create(description: "english")
|
382
325
|
end
|
383
326
|
|
384
327
|
it "returns true" do
|
@@ -404,7 +347,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
404
347
|
context "when the document is not the match" do
|
405
348
|
|
406
349
|
before do
|
407
|
-
Dictionary.
|
350
|
+
Dictionary.
|
408
351
|
create(description: "english", name: "test")
|
409
352
|
end
|
410
353
|
|
@@ -413,12 +356,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
413
356
|
end
|
414
357
|
|
415
358
|
it "returns false" do
|
416
|
-
dictionary.
|
359
|
+
expect(dictionary).to_not be_valid
|
417
360
|
end
|
418
361
|
|
419
362
|
it "adds the uniqueness error" do
|
420
363
|
dictionary.valid?
|
421
|
-
dictionary.errors[:description].
|
364
|
+
expect(dictionary.errors[:description]).to eq([ "is already taken" ])
|
422
365
|
end
|
423
366
|
end
|
424
367
|
end
|
@@ -446,7 +389,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
446
389
|
end
|
447
390
|
|
448
391
|
it "returns true" do
|
449
|
-
dictionary.
|
392
|
+
expect(dictionary).to be_valid
|
450
393
|
end
|
451
394
|
|
452
395
|
context "when subsequently cloning the document" do
|
@@ -456,7 +399,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
456
399
|
end
|
457
400
|
|
458
401
|
it "returns false for the clone" do
|
459
|
-
clone.
|
402
|
+
expect(clone).to_not be_valid
|
460
403
|
end
|
461
404
|
end
|
462
405
|
end
|
@@ -474,12 +417,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
474
417
|
end
|
475
418
|
|
476
419
|
it "returns false" do
|
477
|
-
dictionary.
|
420
|
+
expect(dictionary).to_not be_valid
|
478
421
|
end
|
479
422
|
|
480
423
|
it "adds the uniqueness error" do
|
481
424
|
dictionary.valid?
|
482
|
-
dictionary.errors[:name].
|
425
|
+
expect(dictionary.errors[:name]).to eq([ "is already taken" ])
|
483
426
|
end
|
484
427
|
end
|
485
428
|
|
@@ -492,7 +435,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
492
435
|
end
|
493
436
|
|
494
437
|
it "returns true" do
|
495
|
-
dictionary.
|
438
|
+
expect(dictionary).to be_valid
|
496
439
|
end
|
497
440
|
end
|
498
441
|
|
@@ -511,7 +454,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
511
454
|
end
|
512
455
|
|
513
456
|
it "returns true" do
|
514
|
-
from_db.
|
457
|
+
expect(from_db).to be_valid
|
515
458
|
end
|
516
459
|
|
517
460
|
it "does not touch the database" do
|
@@ -540,7 +483,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
540
483
|
context "when the attribute is not unique" do
|
541
484
|
|
542
485
|
before do
|
543
|
-
Dictionary.
|
486
|
+
Dictionary.create(name: "Oxford")
|
544
487
|
end
|
545
488
|
|
546
489
|
let(:dictionary) do
|
@@ -548,7 +491,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
548
491
|
end
|
549
492
|
|
550
493
|
it "returns false" do
|
551
|
-
dictionary.
|
494
|
+
expect(dictionary).to_not be_valid
|
552
495
|
end
|
553
496
|
end
|
554
497
|
end
|
@@ -575,7 +518,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
575
518
|
end
|
576
519
|
|
577
520
|
it "returns true" do
|
578
|
-
dictionary.
|
521
|
+
expect(dictionary).to be_valid
|
579
522
|
end
|
580
523
|
end
|
581
524
|
|
@@ -590,7 +533,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
590
533
|
end
|
591
534
|
|
592
535
|
it "returns true" do
|
593
|
-
dictionary.
|
536
|
+
expect(dictionary).to be_valid
|
594
537
|
end
|
595
538
|
end
|
596
539
|
|
@@ -605,7 +548,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
605
548
|
end
|
606
549
|
|
607
550
|
it "returns true" do
|
608
|
-
dictionary.
|
551
|
+
expect(dictionary).to be_valid
|
609
552
|
end
|
610
553
|
end
|
611
554
|
|
@@ -620,7 +563,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
620
563
|
end
|
621
564
|
|
622
565
|
it "returns true" do
|
623
|
-
dictionary.
|
566
|
+
expect(dictionary).to be_valid
|
624
567
|
end
|
625
568
|
end
|
626
569
|
|
@@ -637,12 +580,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
637
580
|
end
|
638
581
|
|
639
582
|
it "returns false" do
|
640
|
-
dictionary.
|
583
|
+
expect(dictionary).to_not be_valid
|
641
584
|
end
|
642
585
|
|
643
586
|
it "adds the uniqueness errors" do
|
644
587
|
dictionary.valid?
|
645
|
-
dictionary.errors[:name].
|
588
|
+
expect(dictionary.errors[:name]).to eq([ "is already taken" ])
|
646
589
|
end
|
647
590
|
end
|
648
591
|
|
@@ -653,7 +596,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
653
596
|
end
|
654
597
|
|
655
598
|
it "returns true" do
|
656
|
-
dictionary.
|
599
|
+
expect(dictionary).to be_valid
|
657
600
|
end
|
658
601
|
end
|
659
602
|
end
|
@@ -680,7 +623,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
680
623
|
end
|
681
624
|
|
682
625
|
it "returns true" do
|
683
|
-
dictionary.
|
626
|
+
expect(dictionary).to be_valid
|
684
627
|
end
|
685
628
|
end
|
686
629
|
|
@@ -695,7 +638,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
695
638
|
end
|
696
639
|
|
697
640
|
it "returns true" do
|
698
|
-
dictionary.
|
641
|
+
expect(dictionary).to be_valid
|
699
642
|
end
|
700
643
|
end
|
701
644
|
|
@@ -720,7 +663,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
720
663
|
|
721
664
|
it "should set an error for associated object not being unique" do
|
722
665
|
item.update_attributes(folder_id: personal_folder.id)
|
723
|
-
item.errors.messages[:name].first.
|
666
|
+
expect(item.errors.messages[:name].first).to eq("is already taken")
|
724
667
|
end
|
725
668
|
end
|
726
669
|
|
@@ -735,7 +678,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
735
678
|
end
|
736
679
|
|
737
680
|
it "returns true" do
|
738
|
-
dictionary.
|
681
|
+
expect(dictionary).to be_valid
|
739
682
|
end
|
740
683
|
end
|
741
684
|
|
@@ -750,7 +693,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
750
693
|
end
|
751
694
|
|
752
695
|
it "returns true" do
|
753
|
-
dictionary.
|
696
|
+
expect(dictionary).to be_valid
|
754
697
|
end
|
755
698
|
end
|
756
699
|
|
@@ -767,12 +710,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
767
710
|
end
|
768
711
|
|
769
712
|
it "returns false" do
|
770
|
-
dictionary.
|
713
|
+
expect(dictionary).to_not be_valid
|
771
714
|
end
|
772
715
|
|
773
716
|
it "adds the uniqueness errors" do
|
774
717
|
dictionary.valid?
|
775
|
-
dictionary.errors[:name].
|
718
|
+
expect(dictionary.errors[:name]).to eq([ "is already taken" ])
|
776
719
|
end
|
777
720
|
end
|
778
721
|
|
@@ -783,7 +726,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
783
726
|
end
|
784
727
|
|
785
728
|
it "returns true" do
|
786
|
-
dictionary.
|
729
|
+
expect(dictionary).to be_valid
|
787
730
|
end
|
788
731
|
end
|
789
732
|
|
@@ -806,12 +749,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
806
749
|
end
|
807
750
|
|
808
751
|
it "returns false" do
|
809
|
-
dictionary.
|
752
|
+
expect(dictionary).to_not be_valid
|
810
753
|
end
|
811
754
|
|
812
755
|
it "adds the uniqueness errors" do
|
813
756
|
dictionary.valid?
|
814
|
-
dictionary.errors[:name].
|
757
|
+
expect(dictionary.errors[:name]).to eq([ "is already taken" ])
|
815
758
|
end
|
816
759
|
end
|
817
760
|
end
|
@@ -838,7 +781,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
838
781
|
end
|
839
782
|
|
840
783
|
it "returns true" do
|
841
|
-
dictionary.
|
784
|
+
expect(dictionary).to be_valid
|
842
785
|
end
|
843
786
|
end
|
844
787
|
|
@@ -861,7 +804,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
861
804
|
end
|
862
805
|
|
863
806
|
it "returns true" do
|
864
|
-
dictionary.
|
807
|
+
expect(dictionary).to be_valid
|
865
808
|
end
|
866
809
|
end
|
867
810
|
|
@@ -876,7 +819,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
876
819
|
end
|
877
820
|
|
878
821
|
it "returns true" do
|
879
|
-
dictionary.
|
822
|
+
expect(dictionary).to be_valid
|
880
823
|
end
|
881
824
|
end
|
882
825
|
|
@@ -899,7 +842,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
899
842
|
end
|
900
843
|
|
901
844
|
it "returns true" do
|
902
|
-
dictionary.
|
845
|
+
expect(dictionary).to be_valid
|
903
846
|
end
|
904
847
|
end
|
905
848
|
|
@@ -924,12 +867,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
924
867
|
end
|
925
868
|
|
926
869
|
it "returns false" do
|
927
|
-
dictionary.
|
870
|
+
expect(dictionary).to_not be_valid
|
928
871
|
end
|
929
872
|
|
930
873
|
it "adds the uniqueness errors" do
|
931
874
|
dictionary.valid?
|
932
|
-
dictionary.errors[:name].
|
875
|
+
expect(dictionary.errors[:name]).to eq([ "is already taken" ])
|
933
876
|
end
|
934
877
|
end
|
935
878
|
|
@@ -944,7 +887,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
944
887
|
end
|
945
888
|
|
946
889
|
it "returns true" do
|
947
|
-
dictionary.
|
890
|
+
expect(dictionary).to be_valid
|
948
891
|
end
|
949
892
|
end
|
950
893
|
end
|
@@ -971,7 +914,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
971
914
|
end
|
972
915
|
|
973
916
|
it "returns true" do
|
974
|
-
dictionary.
|
917
|
+
expect(dictionary).to be_valid
|
975
918
|
end
|
976
919
|
end
|
977
920
|
|
@@ -988,12 +931,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
988
931
|
end
|
989
932
|
|
990
933
|
it "returns false" do
|
991
|
-
dictionary.
|
934
|
+
expect(dictionary).to_not be_valid
|
992
935
|
end
|
993
936
|
|
994
937
|
it "adds the uniqueness error" do
|
995
938
|
dictionary.valid?
|
996
|
-
dictionary.errors[:name].
|
939
|
+
expect(dictionary.errors[:name]).to eq([ "is already taken" ])
|
997
940
|
end
|
998
941
|
end
|
999
942
|
|
@@ -1004,7 +947,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1004
947
|
end
|
1005
948
|
|
1006
949
|
it "returns true" do
|
1007
|
-
dictionary.
|
950
|
+
expect(dictionary).to be_valid
|
1008
951
|
end
|
1009
952
|
end
|
1010
953
|
end
|
@@ -1033,7 +976,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1033
976
|
end
|
1034
977
|
|
1035
978
|
it "returns true" do
|
1036
|
-
dictionary.
|
979
|
+
expect(dictionary).to be_valid
|
1037
980
|
end
|
1038
981
|
end
|
1039
982
|
|
@@ -1048,7 +991,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1048
991
|
end
|
1049
992
|
|
1050
993
|
it "returns true" do
|
1051
|
-
dictionary.
|
994
|
+
expect(dictionary).to be_valid
|
1052
995
|
end
|
1053
996
|
end
|
1054
997
|
end
|
@@ -1066,12 +1009,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1066
1009
|
end
|
1067
1010
|
|
1068
1011
|
it "returns false" do
|
1069
|
-
dictionary.
|
1012
|
+
expect(dictionary).to_not be_valid
|
1070
1013
|
end
|
1071
1014
|
|
1072
1015
|
it "adds the uniqueness error" do
|
1073
1016
|
dictionary.valid?
|
1074
|
-
dictionary.errors[:name].
|
1017
|
+
expect(dictionary.errors[:name]).to eq([ "is already taken" ])
|
1075
1018
|
end
|
1076
1019
|
end
|
1077
1020
|
|
@@ -1082,7 +1025,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1082
1025
|
end
|
1083
1026
|
|
1084
1027
|
it "returns true" do
|
1085
|
-
dictionary.
|
1028
|
+
expect(dictionary).to be_valid
|
1086
1029
|
end
|
1087
1030
|
end
|
1088
1031
|
end
|
@@ -1109,7 +1052,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1109
1052
|
end
|
1110
1053
|
|
1111
1054
|
it "returns true" do
|
1112
|
-
dictionary.
|
1055
|
+
expect(dictionary).to be_valid
|
1113
1056
|
end
|
1114
1057
|
end
|
1115
1058
|
end
|
@@ -1135,7 +1078,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1135
1078
|
end
|
1136
1079
|
|
1137
1080
|
it "returns true" do
|
1138
|
-
dictionary.
|
1081
|
+
expect(dictionary).to be_valid
|
1139
1082
|
end
|
1140
1083
|
end
|
1141
1084
|
end
|
@@ -1164,7 +1107,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1164
1107
|
end
|
1165
1108
|
|
1166
1109
|
it "returns true" do
|
1167
|
-
login.
|
1110
|
+
expect(login).to be_valid
|
1168
1111
|
end
|
1169
1112
|
end
|
1170
1113
|
|
@@ -1181,12 +1124,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1181
1124
|
end
|
1182
1125
|
|
1183
1126
|
it "returns false" do
|
1184
|
-
login.
|
1127
|
+
expect(login).to_not be_valid
|
1185
1128
|
end
|
1186
1129
|
|
1187
1130
|
it "adds the uniqueness error" do
|
1188
1131
|
login.valid?
|
1189
|
-
login.errors[:username].
|
1132
|
+
expect(login.errors[:username]).to eq([ "is already taken" ])
|
1190
1133
|
end
|
1191
1134
|
end
|
1192
1135
|
|
@@ -1197,7 +1140,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1197
1140
|
end
|
1198
1141
|
|
1199
1142
|
it "returns true" do
|
1200
|
-
login.
|
1143
|
+
expect(login).to be_valid
|
1201
1144
|
end
|
1202
1145
|
end
|
1203
1146
|
end
|
@@ -1224,7 +1167,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1224
1167
|
end
|
1225
1168
|
|
1226
1169
|
it "returns true" do
|
1227
|
-
login.
|
1170
|
+
expect(login).to be_valid
|
1228
1171
|
end
|
1229
1172
|
end
|
1230
1173
|
|
@@ -1239,7 +1182,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1239
1182
|
end
|
1240
1183
|
|
1241
1184
|
it "returns true" do
|
1242
|
-
login.
|
1185
|
+
expect(login).to be_valid
|
1243
1186
|
end
|
1244
1187
|
end
|
1245
1188
|
|
@@ -1254,7 +1197,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1254
1197
|
end
|
1255
1198
|
|
1256
1199
|
it "returns true" do
|
1257
|
-
login.
|
1200
|
+
expect(login).to be_valid
|
1258
1201
|
end
|
1259
1202
|
end
|
1260
1203
|
|
@@ -1269,7 +1212,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1269
1212
|
end
|
1270
1213
|
|
1271
1214
|
it "returns true" do
|
1272
|
-
login.
|
1215
|
+
expect(login).to be_valid
|
1273
1216
|
end
|
1274
1217
|
end
|
1275
1218
|
|
@@ -1286,12 +1229,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1286
1229
|
end
|
1287
1230
|
|
1288
1231
|
it "returns false" do
|
1289
|
-
login.
|
1232
|
+
expect(login).to_not be_valid
|
1290
1233
|
end
|
1291
1234
|
|
1292
1235
|
it "adds the uniqueness errors" do
|
1293
1236
|
login.valid?
|
1294
|
-
login.errors[:username].
|
1237
|
+
expect(login.errors[:username]).to eq([ "is already taken" ])
|
1295
1238
|
end
|
1296
1239
|
end
|
1297
1240
|
|
@@ -1302,7 +1245,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1302
1245
|
end
|
1303
1246
|
|
1304
1247
|
it "returns true" do
|
1305
|
-
login.
|
1248
|
+
expect(login).to be_valid
|
1306
1249
|
end
|
1307
1250
|
end
|
1308
1251
|
end
|
@@ -1329,7 +1272,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1329
1272
|
end
|
1330
1273
|
|
1331
1274
|
it "returns true" do
|
1332
|
-
login.
|
1275
|
+
expect(login).to be_valid
|
1333
1276
|
end
|
1334
1277
|
end
|
1335
1278
|
|
@@ -1346,12 +1289,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1346
1289
|
end
|
1347
1290
|
|
1348
1291
|
it "returns false" do
|
1349
|
-
login.
|
1292
|
+
expect(login).to_not be_valid
|
1350
1293
|
end
|
1351
1294
|
|
1352
1295
|
it "adds the uniqueness error" do
|
1353
1296
|
login.valid?
|
1354
|
-
login.errors[:username].
|
1297
|
+
expect(login.errors[:username]).to eq([ "is already taken" ])
|
1355
1298
|
end
|
1356
1299
|
end
|
1357
1300
|
|
@@ -1362,7 +1305,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1362
1305
|
end
|
1363
1306
|
|
1364
1307
|
it "returns true" do
|
1365
|
-
login.
|
1308
|
+
expect(login).to be_valid
|
1366
1309
|
end
|
1367
1310
|
end
|
1368
1311
|
end
|
@@ -1391,7 +1334,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1391
1334
|
end
|
1392
1335
|
|
1393
1336
|
it "returns true" do
|
1394
|
-
login.
|
1337
|
+
expect(login).to be_valid
|
1395
1338
|
end
|
1396
1339
|
end
|
1397
1340
|
|
@@ -1406,7 +1349,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1406
1349
|
end
|
1407
1350
|
|
1408
1351
|
it "returns true" do
|
1409
|
-
login.
|
1352
|
+
expect(login).to be_valid
|
1410
1353
|
end
|
1411
1354
|
end
|
1412
1355
|
end
|
@@ -1424,12 +1367,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1424
1367
|
end
|
1425
1368
|
|
1426
1369
|
it "returns false" do
|
1427
|
-
login.
|
1370
|
+
expect(login).to_not be_valid
|
1428
1371
|
end
|
1429
1372
|
|
1430
1373
|
it "adds the uniqueness error" do
|
1431
1374
|
login.valid?
|
1432
|
-
login.errors[:username].
|
1375
|
+
expect(login.errors[:username]).to eq([ "is already taken" ])
|
1433
1376
|
end
|
1434
1377
|
end
|
1435
1378
|
|
@@ -1440,7 +1383,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1440
1383
|
end
|
1441
1384
|
|
1442
1385
|
it "returns true" do
|
1443
|
-
login.
|
1386
|
+
expect(login).to be_valid
|
1444
1387
|
end
|
1445
1388
|
end
|
1446
1389
|
end
|
@@ -1467,7 +1410,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1467
1410
|
end
|
1468
1411
|
|
1469
1412
|
it "returns true" do
|
1470
|
-
login.
|
1413
|
+
expect(login).to be_valid
|
1471
1414
|
end
|
1472
1415
|
end
|
1473
1416
|
end
|
@@ -1493,7 +1436,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1493
1436
|
end
|
1494
1437
|
|
1495
1438
|
it "returns true" do
|
1496
|
-
login.
|
1439
|
+
expect(login).to be_valid
|
1497
1440
|
end
|
1498
1441
|
end
|
1499
1442
|
end
|
@@ -1587,7 +1530,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1587
1530
|
end
|
1588
1531
|
|
1589
1532
|
it "returns true" do
|
1590
|
-
def_two.
|
1533
|
+
expect(def_two).to be_valid
|
1591
1534
|
end
|
1592
1535
|
end
|
1593
1536
|
end
|
@@ -1615,7 +1558,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1615
1558
|
end
|
1616
1559
|
|
1617
1560
|
it "returns true" do
|
1618
|
-
definition.
|
1561
|
+
expect(definition).to be_valid
|
1619
1562
|
end
|
1620
1563
|
end
|
1621
1564
|
|
@@ -1632,12 +1575,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1632
1575
|
end
|
1633
1576
|
|
1634
1577
|
it "returns false" do
|
1635
|
-
definition.
|
1578
|
+
expect(definition).to_not be_valid
|
1636
1579
|
end
|
1637
1580
|
|
1638
1581
|
it "adds the uniqueness error" do
|
1639
1582
|
definition.valid?
|
1640
|
-
definition.errors[:description].
|
1583
|
+
expect(definition.errors[:description]).to eq([ "is already taken" ])
|
1641
1584
|
end
|
1642
1585
|
end
|
1643
1586
|
|
@@ -1648,7 +1591,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1648
1591
|
end
|
1649
1592
|
|
1650
1593
|
it "returns true" do
|
1651
|
-
definition.
|
1594
|
+
expect(definition).to be_valid
|
1652
1595
|
end
|
1653
1596
|
end
|
1654
1597
|
end
|
@@ -1677,7 +1620,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1677
1620
|
end
|
1678
1621
|
|
1679
1622
|
it "returns true" do
|
1680
|
-
definition.
|
1623
|
+
expect(definition).to be_valid
|
1681
1624
|
end
|
1682
1625
|
end
|
1683
1626
|
|
@@ -1698,7 +1641,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1698
1641
|
end
|
1699
1642
|
|
1700
1643
|
it "returns true" do
|
1701
|
-
definition.
|
1644
|
+
expect(definition).to be_valid
|
1702
1645
|
end
|
1703
1646
|
end
|
1704
1647
|
|
@@ -1716,7 +1659,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1716
1659
|
end
|
1717
1660
|
|
1718
1661
|
it "returns true" do
|
1719
|
-
definition.
|
1662
|
+
expect(definition).to be_valid
|
1720
1663
|
end
|
1721
1664
|
end
|
1722
1665
|
|
@@ -1737,7 +1680,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1737
1680
|
end
|
1738
1681
|
|
1739
1682
|
it "returns true" do
|
1740
|
-
definition.
|
1683
|
+
expect(definition).to be_valid
|
1741
1684
|
end
|
1742
1685
|
end
|
1743
1686
|
|
@@ -1760,12 +1703,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1760
1703
|
end
|
1761
1704
|
|
1762
1705
|
it "returns false" do
|
1763
|
-
definition.
|
1706
|
+
expect(definition).to_not be_valid
|
1764
1707
|
end
|
1765
1708
|
|
1766
1709
|
it "adds the uniqueness errors" do
|
1767
1710
|
definition.valid?
|
1768
|
-
definition.errors[:description].
|
1711
|
+
expect(definition.errors[:description]).to eq([ "is already taken" ])
|
1769
1712
|
end
|
1770
1713
|
end
|
1771
1714
|
|
@@ -1779,7 +1722,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1779
1722
|
end
|
1780
1723
|
|
1781
1724
|
it "returns true" do
|
1782
|
-
definition.
|
1725
|
+
expect(definition).to be_valid
|
1783
1726
|
end
|
1784
1727
|
end
|
1785
1728
|
end
|
@@ -1809,7 +1752,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1809
1752
|
end
|
1810
1753
|
|
1811
1754
|
it "returns true" do
|
1812
|
-
definition.
|
1755
|
+
expect(definition).to be_valid
|
1813
1756
|
end
|
1814
1757
|
end
|
1815
1758
|
|
@@ -1832,7 +1775,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1832
1775
|
end
|
1833
1776
|
|
1834
1777
|
it "returns true" do
|
1835
|
-
definition.
|
1778
|
+
expect(definition).to be_valid
|
1836
1779
|
end
|
1837
1780
|
end
|
1838
1781
|
|
@@ -1850,7 +1793,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1850
1793
|
end
|
1851
1794
|
|
1852
1795
|
it "returns true" do
|
1853
|
-
definition.
|
1796
|
+
expect(definition).to be_valid
|
1854
1797
|
end
|
1855
1798
|
end
|
1856
1799
|
|
@@ -1873,7 +1816,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1873
1816
|
end
|
1874
1817
|
|
1875
1818
|
it "returns true" do
|
1876
|
-
definition.
|
1819
|
+
expect(definition).to be_valid
|
1877
1820
|
end
|
1878
1821
|
end
|
1879
1822
|
|
@@ -1898,12 +1841,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1898
1841
|
end
|
1899
1842
|
|
1900
1843
|
it "returns false" do
|
1901
|
-
definition.
|
1844
|
+
expect(definition).to_not be_valid
|
1902
1845
|
end
|
1903
1846
|
|
1904
1847
|
it "adds the uniqueness errors" do
|
1905
1848
|
definition.valid?
|
1906
|
-
definition.errors[:description].
|
1849
|
+
expect(definition.errors[:description]).to eq([ "is already taken" ])
|
1907
1850
|
end
|
1908
1851
|
end
|
1909
1852
|
|
@@ -1918,7 +1861,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1918
1861
|
end
|
1919
1862
|
|
1920
1863
|
it "returns true" do
|
1921
|
-
definition.
|
1864
|
+
expect(definition).to be_valid
|
1922
1865
|
end
|
1923
1866
|
end
|
1924
1867
|
end
|
@@ -1945,7 +1888,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1945
1888
|
end
|
1946
1889
|
|
1947
1890
|
it "returns true" do
|
1948
|
-
definition.
|
1891
|
+
expect(definition).to be_valid
|
1949
1892
|
end
|
1950
1893
|
end
|
1951
1894
|
|
@@ -1962,12 +1905,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1962
1905
|
end
|
1963
1906
|
|
1964
1907
|
it "returns false" do
|
1965
|
-
definition.
|
1908
|
+
expect(definition).to_not be_valid
|
1966
1909
|
end
|
1967
1910
|
|
1968
1911
|
it "adds the uniqueness error" do
|
1969
1912
|
definition.valid?
|
1970
|
-
definition.errors[:description].
|
1913
|
+
expect(definition.errors[:description]).to eq([ "is already taken" ])
|
1971
1914
|
end
|
1972
1915
|
end
|
1973
1916
|
|
@@ -1978,7 +1921,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
1978
1921
|
end
|
1979
1922
|
|
1980
1923
|
it "returns true" do
|
1981
|
-
definition.
|
1924
|
+
expect(definition).to be_valid
|
1982
1925
|
end
|
1983
1926
|
end
|
1984
1927
|
end
|
@@ -2007,7 +1950,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2007
1950
|
end
|
2008
1951
|
|
2009
1952
|
it "returns true" do
|
2010
|
-
definition.
|
1953
|
+
expect(definition).to be_valid
|
2011
1954
|
end
|
2012
1955
|
end
|
2013
1956
|
|
@@ -2022,7 +1965,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2022
1965
|
end
|
2023
1966
|
|
2024
1967
|
it "returns true" do
|
2025
|
-
definition.
|
1968
|
+
expect(definition).to be_valid
|
2026
1969
|
end
|
2027
1970
|
end
|
2028
1971
|
end
|
@@ -2040,12 +1983,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2040
1983
|
end
|
2041
1984
|
|
2042
1985
|
it "returns false" do
|
2043
|
-
definition.
|
1986
|
+
expect(definition).to_not be_valid
|
2044
1987
|
end
|
2045
1988
|
|
2046
1989
|
it "adds the uniqueness error" do
|
2047
1990
|
definition.valid?
|
2048
|
-
definition.errors[:description].
|
1991
|
+
expect(definition.errors[:description]).to eq([ "is already taken" ])
|
2049
1992
|
end
|
2050
1993
|
end
|
2051
1994
|
|
@@ -2056,7 +1999,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2056
1999
|
end
|
2057
2000
|
|
2058
2001
|
it "returns true" do
|
2059
|
-
definition.
|
2002
|
+
expect(definition).to be_valid
|
2060
2003
|
end
|
2061
2004
|
end
|
2062
2005
|
end
|
@@ -2083,7 +2026,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2083
2026
|
end
|
2084
2027
|
|
2085
2028
|
it "returns true" do
|
2086
|
-
definition.
|
2029
|
+
expect(definition).to be_valid
|
2087
2030
|
end
|
2088
2031
|
end
|
2089
2032
|
end
|
@@ -2109,7 +2052,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2109
2052
|
end
|
2110
2053
|
|
2111
2054
|
it "returns true" do
|
2112
|
-
definition.
|
2055
|
+
expect(definition).to be_valid
|
2113
2056
|
end
|
2114
2057
|
end
|
2115
2058
|
end
|
@@ -2224,7 +2167,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2224
2167
|
end
|
2225
2168
|
|
2226
2169
|
it "returns true" do
|
2227
|
-
word_origin.
|
2170
|
+
expect(word_origin).to be_valid
|
2228
2171
|
end
|
2229
2172
|
end
|
2230
2173
|
|
@@ -2241,12 +2184,12 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2241
2184
|
end
|
2242
2185
|
|
2243
2186
|
it "returns false" do
|
2244
|
-
word_origin.
|
2187
|
+
expect(word_origin).to_not be_valid
|
2245
2188
|
end
|
2246
2189
|
|
2247
2190
|
it "adds the uniqueness error" do
|
2248
2191
|
word_origin.valid?
|
2249
|
-
word_origin.errors[:origin_id].
|
2192
|
+
expect(word_origin.errors[:origin_id]).to eq([ "is already taken" ])
|
2250
2193
|
end
|
2251
2194
|
end
|
2252
2195
|
|
@@ -2257,7 +2200,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2257
2200
|
end
|
2258
2201
|
|
2259
2202
|
it "returns true" do
|
2260
|
-
word_origin.
|
2203
|
+
expect(word_origin).to be_valid
|
2261
2204
|
end
|
2262
2205
|
end
|
2263
2206
|
end
|
@@ -2284,7 +2227,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2284
2227
|
end
|
2285
2228
|
|
2286
2229
|
it "returns true" do
|
2287
|
-
word_origin.
|
2230
|
+
expect(word_origin).to be_valid
|
2288
2231
|
end
|
2289
2232
|
end
|
2290
2233
|
end
|
@@ -2310,7 +2253,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2310
2253
|
end
|
2311
2254
|
|
2312
2255
|
it "returns true" do
|
2313
|
-
word_origin.
|
2256
|
+
expect(word_origin).to be_valid
|
2314
2257
|
end
|
2315
2258
|
end
|
2316
2259
|
end
|
@@ -2332,7 +2275,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2332
2275
|
end
|
2333
2276
|
|
2334
2277
|
it "always returns true" do
|
2335
|
-
pronunciation.
|
2278
|
+
expect(pronunciation).to be_valid
|
2336
2279
|
end
|
2337
2280
|
end
|
2338
2281
|
end
|
@@ -2348,7 +2291,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2348
2291
|
end
|
2349
2292
|
|
2350
2293
|
it "adds the validation only to the instance" do
|
2351
|
-
validators.
|
2294
|
+
expect(validators).to eq([ described_class ])
|
2352
2295
|
end
|
2353
2296
|
end
|
2354
2297
|
|
@@ -2369,8 +2312,8 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2369
2312
|
|
2370
2313
|
it "should be invalid" do
|
2371
2314
|
subclass_document_with_duplicated_name.tap do |d|
|
2372
|
-
d.
|
2373
|
-
d.errors[:name].
|
2315
|
+
expect(d).to be_invalid
|
2316
|
+
expect(d.errors[:name]).to eq([ "is already taken" ])
|
2374
2317
|
end
|
2375
2318
|
end
|
2376
2319
|
end
|
@@ -2383,7 +2326,7 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2383
2326
|
end
|
2384
2327
|
|
2385
2328
|
let!(:person) do
|
2386
|
-
Person.create(ssn: "132-11-1111", username: "
|
2329
|
+
Person.create(ssn: "132-11-1111", username: "aaasdaffff")
|
2387
2330
|
end
|
2388
2331
|
|
2389
2332
|
after do
|
@@ -2392,8 +2335,8 @@ describe Mongoid::Validations::UniquenessValidator do
|
|
2392
2335
|
|
2393
2336
|
it "transfers the options to the cloned session" do
|
2394
2337
|
expect {
|
2395
|
-
Person.
|
2396
|
-
}.to raise_error
|
2338
|
+
Person.create!(ssn: "132-11-1111", username: "asdfsdfA")
|
2339
|
+
}.to raise_error
|
2397
2340
|
end
|
2398
2341
|
end
|
2399
2342
|
end
|