mongoid 3.1.6 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +479 -8
 - data/README.md +10 -7
 - data/lib/config/locales/en.yml +34 -20
 - data/lib/mongoid.rb +10 -76
 - data/lib/mongoid/atomic.rb +3 -14
 - data/lib/mongoid/atomic/paths/embedded.rb +0 -30
 - data/lib/mongoid/atomic/paths/embedded/many.rb +1 -1
 - data/lib/mongoid/atomic/paths/embedded/one.rb +1 -1
 - data/lib/mongoid/atomic/paths/root.rb +0 -13
 - data/lib/mongoid/attributes.rb +65 -101
 - 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} +32 -2
 - data/lib/mongoid/composable.rb +105 -0
 - data/lib/mongoid/config.rb +3 -9
 - data/lib/mongoid/config/options.rb +1 -1
 - data/lib/mongoid/contextual.rb +2 -0
 - data/lib/mongoid/contextual/aggregable/memory.rb +2 -2
 - data/lib/mongoid/contextual/aggregable/mongo.rb +7 -9
 - data/lib/mongoid/contextual/atomic.rb +53 -53
 - data/lib/mongoid/contextual/geo_near.rb +1 -1
 - data/lib/mongoid/contextual/map_reduce.rb +4 -2
 - data/lib/mongoid/contextual/memory.rb +23 -11
 - data/lib/mongoid/contextual/mongo.rb +75 -57
 - data/lib/mongoid/contextual/none.rb +90 -0
 - data/lib/mongoid/contextual/text_search.rb +178 -0
 - data/lib/mongoid/copyable.rb +2 -3
 - data/lib/mongoid/criteria.rb +39 -34
 - data/lib/mongoid/criteria/#findable.rb# +141 -0
 - data/lib/mongoid/{criterion → criteria}/findable.rb +7 -47
 - 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 +28 -8
 - data/lib/mongoid/criteria/permission.rb +70 -0
 - data/lib/mongoid/{criterion/scoping.rb → criteria/scopable.rb} +2 -2
 - data/lib/mongoid/document.rb +39 -24
 - data/lib/mongoid/errors.rb +4 -1
 - data/lib/mongoid/errors/document_not_destroyed.rb +25 -0
 - data/lib/mongoid/errors/document_not_found.rb +2 -1
 - data/lib/mongoid/errors/invalid_storage_options.rb +1 -1
 - data/lib/mongoid/errors/invalid_storage_parent.rb +26 -0
 - data/lib/mongoid/errors/invalid_value.rb +16 -0
 - data/lib/mongoid/errors/mongoid_error.rb +1 -1
 - data/lib/mongoid/errors/readonly_document.rb +24 -0
 - data/lib/mongoid/extensions.rb +15 -7
 - data/lib/mongoid/extensions/array.rb +3 -3
 - data/lib/mongoid/extensions/big_decimal.rb +1 -1
 - data/lib/mongoid/extensions/boolean.rb +15 -17
 - data/lib/mongoid/extensions/date.rb +1 -1
 - data/lib/mongoid/extensions/date_time.rb +3 -3
 - data/lib/mongoid/extensions/float.rb +2 -1
 - data/lib/mongoid/extensions/hash.rb +3 -3
 - data/lib/mongoid/extensions/integer.rb +1 -1
 - data/lib/mongoid/extensions/object.rb +7 -7
 - data/lib/mongoid/extensions/object_id.rb +5 -5
 - data/lib/mongoid/extensions/range.rb +9 -3
 - data/lib/mongoid/extensions/regexp.rb +1 -1
 - data/lib/mongoid/extensions/set.rb +1 -1
 - data/lib/mongoid/extensions/string.rb +6 -18
 - data/lib/mongoid/extensions/symbol.rb +1 -1
 - data/lib/mongoid/extensions/time.rb +3 -3
 - data/lib/mongoid/extensions/time_with_zone.rb +1 -1
 - data/lib/mongoid/factory.rb +8 -6
 - data/lib/mongoid/fields.rb +41 -8
 - data/lib/mongoid/fields/foreign_key.rb +3 -3
 - data/lib/mongoid/fields/localized.rb +1 -1
 - data/lib/mongoid/fields/standard.rb +5 -17
 - data/lib/mongoid/fields/validators/macro.rb +15 -5
 - data/lib/mongoid/{finders.rb → findable.rb} +35 -7
 - 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} +30 -62
 - data/lib/mongoid/log_subscriber.rb +55 -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 +2 -2
 - 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 +216 -0
 - data/lib/mongoid/persistable/creatable.rb +189 -0
 - data/lib/mongoid/persistable/deletable.rb +149 -0
 - data/lib/mongoid/persistable/destroyable.rb +60 -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 +153 -0
 - data/lib/mongoid/persistable/upsertable.rb +55 -0
 - data/lib/mongoid/positional.rb +71 -0
 - data/lib/mongoid/query_cache.rb +255 -0
 - data/lib/mongoid/railtie.rb +34 -60
 - data/lib/mongoid/railties/database.rake +9 -25
 - data/lib/mongoid/relations.rb +11 -25
 - data/lib/mongoid/relations/accessors.rb +15 -51
 - data/lib/mongoid/relations/auto_save.rb +15 -36
 - data/lib/mongoid/relations/binding.rb +2 -25
 - data/lib/mongoid/relations/bindings/embedded/in.rb +1 -1
 - 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 +4 -2
 - data/lib/mongoid/relations/builder.rb +1 -1
 - data/lib/mongoid/relations/builders.rb +2 -2
 - data/lib/mongoid/relations/builders/embedded/one.rb +1 -1
 - data/lib/mongoid/relations/builders/nested_attributes/many.rb +10 -13
 - data/lib/mongoid/relations/builders/nested_attributes/one.rb +5 -6
 - 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 +46 -0
 - data/lib/mongoid/relations/eager/base.rb +149 -0
 - data/lib/mongoid/relations/eager/belongs_to.rb +31 -0
 - data/lib/mongoid/relations/eager/has_and_belongs_to_many.rb +47 -0
 - data/lib/mongoid/relations/eager/has_many.rb +38 -0
 - data/lib/mongoid/relations/eager/has_one.rb +30 -0
 - data/lib/mongoid/relations/embedded/batchable.rb +4 -5
 - data/lib/mongoid/relations/embedded/in.rb +4 -4
 - data/lib/mongoid/relations/embedded/many.rb +14 -32
 - data/lib/mongoid/relations/embedded/one.rb +1 -1
 - data/lib/mongoid/relations/macros.rb +3 -4
 - data/lib/mongoid/relations/many.rb +51 -31
 - data/lib/mongoid/relations/marshalable.rb +3 -3
 - data/lib/mongoid/relations/metadata.rb +14 -79
 - data/lib/mongoid/relations/nested_builder.rb +2 -2
 - data/lib/mongoid/relations/one.rb +1 -1
 - data/lib/mongoid/relations/options.rb +1 -0
 - data/lib/mongoid/relations/polymorphic.rb +0 -1
 - data/lib/mongoid/relations/proxy.rb +21 -41
 - data/lib/mongoid/relations/referenced/in.rb +4 -20
 - data/lib/mongoid/relations/referenced/many.rb +22 -35
 - data/lib/mongoid/relations/referenced/many_to_many.rb +19 -42
 - data/lib/mongoid/relations/referenced/one.rb +6 -25
 - data/lib/mongoid/relations/synchronization.rb +4 -4
 - data/lib/mongoid/relations/targets/enumerable.rb +10 -10
 - data/lib/mongoid/relations/touchable.rb +34 -1
 - data/lib/mongoid/{reloading.rb → reloadable.rb} +7 -5
 - data/lib/mongoid/{scoping.rb → scopable.rb} +36 -36
 - data/lib/mongoid/selectable.rb +59 -0
 - data/lib/mongoid/{serialization.rb → serializable.rb} +11 -2
 - data/lib/mongoid/sessions.rb +37 -345
 - data/lib/mongoid/sessions/factory.rb +2 -0
 - data/lib/mongoid/sessions/options.rb +185 -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 +16 -3
 - data/lib/mongoid/{sharding.rb → shardable.rb} +5 -1
 - data/lib/mongoid/{state.rb → stateful.rb} +13 -1
 - data/lib/mongoid/support/query_counter.rb +23 -0
 - data/lib/mongoid/tasks/database.rake +31 -0
 - data/lib/mongoid/tasks/database.rb +107 -0
 - data/lib/mongoid/threaded.rb +26 -172
 - data/lib/mongoid/threaded/lifecycle.rb +0 -28
 - data/lib/mongoid/timestamps/updated/short.rb +2 -2
 - data/lib/mongoid/{hierarchy.rb → traversable.rb} +15 -7
 - data/lib/mongoid/{validations.rb → validatable.rb} +23 -10
 - data/lib/mongoid/{validations → validatable}/associated.rb +4 -2
 - 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 +25 -21
 - data/lib/mongoid/version.rb +1 -1
 - data/lib/rails/generators/mongoid/config/templates/mongoid.yml +46 -25
 - 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 +0 -122
 - data/lib/support/ruby_version.rb +1 -1
 - data/spec/app/models/account.rb +2 -6
 - data/spec/app/models/acolyte.rb +2 -1
 - data/spec/app/models/actor.rb +0 -1
 - data/spec/app/models/address.rb +8 -3
 - data/spec/app/models/animal.rb +1 -1
 - data/spec/app/models/appointment.rb +3 -3
 - 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/contextable_item.rb +5 -0
 - 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/dog.rb +1 -1
 - data/spec/app/models/draft.rb +9 -0
 - 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/edit.rb +5 -0
 - data/spec/app/models/even.rb +7 -0
 - data/spec/app/models/event.rb +1 -1
 - 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 +1 -3
 - data/spec/app/models/id_key.rb +6 -0
 - 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/line_item.rb +1 -1
 - data/spec/app/models/login.rb +1 -1
 - data/spec/app/models/message.rb +8 -0
 - data/spec/app/models/movie.rb +1 -0
 - data/spec/app/models/name.rb +3 -3
 - data/spec/app/models/note.rb +3 -1
 - data/spec/app/models/odd.rb +7 -0
 - data/spec/app/models/oscar.rb +1 -1
 - data/spec/app/models/parent_doc.rb +1 -1
 - data/spec/app/models/person.rb +16 -10
 - data/spec/app/models/phone.rb +1 -3
 - data/spec/app/models/player.rb +3 -3
 - data/spec/app/models/post.rb +5 -3
 - data/spec/app/models/preference.rb +1 -1
 - data/spec/app/models/quiz.rb +0 -3
 - data/spec/app/models/record.rb +10 -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/symptom.rb +1 -1
 - 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 +3 -3
 - data/spec/app/models/video.rb +1 -5
 - data/spec/app/models/wiki_page.rb +2 -5
 - 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_spec.rb# +365 -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} +474 -592
 - data/spec/mongoid/attributes/readonly_spec.rb +58 -18
 - data/spec/mongoid/attributes_spec.rb +349 -434
 - data/spec/mongoid/{dirty_spec.rb → changeable_spec.rb} +203 -153
 - 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 +78 -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 +156 -94
 - data/spec/mongoid/contextual/mongo_spec.rb +238 -150
 - data/spec/mongoid/contextual/none_spec.rb +127 -0
 - data/spec/mongoid/contextual/text_search_spec.rb +209 -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 +1252 -0
 - data/spec/mongoid/{criterion/scoping_spec.rb → criteria/scopable_spec.rb} +37 -37
 - data/spec/mongoid/criteria_spec.rb +715 -2421
 - data/spec/mongoid/document_spec.rb +171 -121
 - 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_destroyed_spec.rb +33 -0
 - 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 +5 -5
 - 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 +8 -8
 - 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/readonly_document_spec.rb +29 -0
 - 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 +8 -8
 - 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 +29 -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 +38 -23
 - data/spec/mongoid/fields/standard_spec.rb +12 -12
 - data/spec/mongoid/fields_spec.rb +263 -217
 - data/spec/mongoid/findable_spec.rb +509 -0
 - 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} +117 -116
 - data/spec/mongoid/log_subscriber_spec.rb +75 -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/matchable/ne_spec.rb +46 -0
 - 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 +553 -0
 - data/spec/mongoid/persistable/deletable_spec.rb +218 -0
 - data/spec/mongoid/persistable/destroyable_spec.rb +192 -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 +498 -0
 - data/spec/mongoid/persistable/settable_spec.rb +162 -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} +14 -19
 - data/spec/mongoid/query_cache_spec.rb +263 -0
 - 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 +37 -17
 - data/spec/mongoid/relations/bindings/embedded/in_spec.rb +12 -12
 - data/spec/mongoid/relations/bindings/embedded/many_spec.rb +3 -3
 - data/spec/mongoid/relations/bindings/embedded/one_spec.rb +5 -5
 - data/spec/mongoid/relations/bindings/referenced/in_spec.rb +26 -26
 - data/spec/mongoid/relations/bindings/referenced/many_spec.rb +10 -10
 - data/spec/mongoid/relations/bindings/referenced/many_to_many_spec.rb +19 -19
 - data/spec/mongoid/relations/bindings/referenced/one_spec.rb +12 -12
 - 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 +24 -35
 - 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 +12 -25
 - data/spec/mongoid/relations/builders_spec.rb +21 -21
 - data/spec/mongoid/relations/cascading/delete_spec.rb +9 -9
 - data/spec/mongoid/relations/cascading/destroy_spec.rb +6 -6
 - data/spec/mongoid/relations/cascading/nullify_spec.rb +4 -4
 - data/spec/mongoid/relations/cascading/restrict_spec.rb +7 -7
 - 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 +117 -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 +56 -57
 - data/spec/mongoid/relations/embedded/many_spec.rb +467 -372
 - data/spec/mongoid/relations/embedded/one_spec.rb +108 -141
 - data/spec/mongoid/relations/macros_spec.rb +108 -102
 - data/spec/mongoid/relations/metadata_spec.rb +180 -255
 - 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 +587 -527
 - data/spec/mongoid/relations/referenced/many_to_many_spec.rb +401 -424
 - data/spec/mongoid/relations/referenced/one_spec.rb +149 -264
 - 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 +118 -118
 - data/spec/mongoid/relations/touchable_spec.rb +333 -0
 - data/spec/mongoid/relations_spec.rb +16 -15
 - data/spec/mongoid/{reloading_spec.rb → reloadable_spec.rb} +38 -55
 - data/spec/mongoid/{scoping_spec.rb → scopable_spec.rb} +89 -164
 - data/spec/mongoid/selectable_spec.rb +134 -0
 - data/spec/mongoid/{serialization_spec.rb → serializable_spec.rb} +129 -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 +108 -0
 - data/spec/mongoid/sessions_spec.rb +319 -178
 - data/spec/mongoid/{sharding_spec.rb → shardable_spec.rb} +8 -8
 - data/spec/mongoid/{state_spec.rb → stateful_spec.rb} +36 -11
 - data/spec/mongoid/tasks/database_rake_spec.rb +285 -0
 - data/spec/mongoid/tasks/database_spec.rb +160 -0
 - 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/timeless_spec.rb +6 -6
 - data/spec/mongoid/timestamps/updated/short_spec.rb +11 -11
 - data/spec/mongoid/timestamps/updated_spec.rb +9 -13
 - data/spec/mongoid/timestamps_spec.rb +9 -13
 - data/spec/mongoid/{hierarchy_spec.rb → traversable_spec.rb} +19 -19
 - data/spec/mongoid/{validations → validatable}/associated_spec.rb +45 -22
 - data/spec/mongoid/{validations → validatable}/format_spec.rb +6 -6
 - data/spec/mongoid/{validations → validatable}/length_spec.rb +14 -14
 - data/spec/mongoid/{validations → validatable}/numericality_spec.rb +1 -1
 - data/spec/mongoid/{validations → validatable}/presence_spec.rb +37 -44
 - data/spec/mongoid/{validations → validatable}/uniqueness_spec.rb +184 -192
 - data/spec/mongoid/{validations_spec.rb → validatable_spec.rb} +28 -28
 - data/spec/mongoid_spec.rb +8 -8
 - data/spec/rails/mongoid_spec.rb +19 -335
 - data/spec/spec_helper.rb +31 -13
 - metadata +303 -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/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/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/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/finders_spec.rb +0 -321
 - 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/ne_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::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,11 +454,11 @@ 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
         
     | 
| 
       518 
     | 
    
         
            -
                              Dictionary. 
     | 
| 
      
 461 
     | 
    
         
            +
                              expect(Dictionary).to receive(:where).never
         
     | 
| 
       519 
462 
     | 
    
         
             
                              from_db.valid?
         
     | 
| 
       520 
463 
     | 
    
         
             
                            end
         
     | 
| 
       521 
464 
     | 
    
         
             
                          end
         
     | 
| 
         @@ -527,11 +470,11 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       527 
470 
     | 
    
         | 
| 
       528 
471 
     | 
    
         
             
                      before do
         
     | 
| 
       529 
472 
     | 
    
         
             
                        Dictionary.validates_uniqueness_of :name
         
     | 
| 
       530 
     | 
    
         
            -
                        Dictionary.default_scope(Dictionary.where(year: 1990))
         
     | 
| 
      
 473 
     | 
    
         
            +
                        Dictionary.default_scope(->{ Dictionary.where(year: 1990) })
         
     | 
| 
       531 
474 
     | 
    
         
             
                      end
         
     | 
| 
       532 
475 
     | 
    
         | 
| 
       533 
476 
     | 
    
         
             
                      after do
         
     | 
| 
       534 
     | 
    
         
            -
                        Dictionary. 
     | 
| 
      
 477 
     | 
    
         
            +
                        Dictionary.default_scoping = nil
         
     | 
| 
       535 
478 
     | 
    
         
             
                        Dictionary.reset_callbacks(:validate)
         
     | 
| 
       536 
479 
     | 
    
         
             
                      end
         
     | 
| 
       537 
480 
     | 
    
         | 
| 
         @@ -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,12 +1025,19 @@ 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
         
     | 
| 
       1089 
1032 
     | 
    
         
             
                    end
         
     | 
| 
       1090 
1033 
     | 
    
         | 
| 
      
 1034 
     | 
    
         
            +
                    context "when not allowing nil" do
         
     | 
| 
      
 1035 
     | 
    
         
            +
             
     | 
| 
      
 1036 
     | 
    
         
            +
                      it "raises a validation error" do
         
     | 
| 
      
 1037 
     | 
    
         
            +
                        expect { LineItem.create! }.to raise_error Mongoid::Errors::Validations
         
     | 
| 
      
 1038 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1039 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1040 
     | 
    
         
            +
             
     | 
| 
       1091 
1041 
     | 
    
         
             
                    context "when allowing nil" do
         
     | 
| 
       1092 
1042 
     | 
    
         | 
| 
       1093 
1043 
     | 
    
         
             
                      before do
         
     | 
| 
         @@ -1109,7 +1059,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1109 
1059 
     | 
    
         
             
                        end
         
     | 
| 
       1110 
1060 
     | 
    
         | 
| 
       1111 
1061 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1112 
     | 
    
         
            -
                          dictionary. 
     | 
| 
      
 1062 
     | 
    
         
            +
                          expect(dictionary).to be_valid
         
     | 
| 
       1113 
1063 
     | 
    
         
             
                        end
         
     | 
| 
       1114 
1064 
     | 
    
         
             
                      end
         
     | 
| 
       1115 
1065 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1135,7 +1085,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1135 
1085 
     | 
    
         
             
                        end
         
     | 
| 
       1136 
1086 
     | 
    
         | 
| 
       1137 
1087 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1138 
     | 
    
         
            -
                          dictionary. 
     | 
| 
      
 1088 
     | 
    
         
            +
                          expect(dictionary).to be_valid
         
     | 
| 
       1139 
1089 
     | 
    
         
             
                        end
         
     | 
| 
       1140 
1090 
     | 
    
         
             
                      end
         
     | 
| 
       1141 
1091 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1164,7 +1114,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1164 
1114 
     | 
    
         
             
                        end
         
     | 
| 
       1165 
1115 
     | 
    
         | 
| 
       1166 
1116 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1167 
     | 
    
         
            -
                          login. 
     | 
| 
      
 1117 
     | 
    
         
            +
                          expect(login).to be_valid
         
     | 
| 
       1168 
1118 
     | 
    
         
             
                        end
         
     | 
| 
       1169 
1119 
     | 
    
         
             
                      end
         
     | 
| 
       1170 
1120 
     | 
    
         | 
| 
         @@ -1181,12 +1131,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1181 
1131 
     | 
    
         
             
                          end
         
     | 
| 
       1182 
1132 
     | 
    
         | 
| 
       1183 
1133 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       1184 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1134 
     | 
    
         
            +
                            expect(login).to_not be_valid
         
     | 
| 
       1185 
1135 
     | 
    
         
             
                          end
         
     | 
| 
       1186 
1136 
     | 
    
         | 
| 
       1187 
1137 
     | 
    
         
             
                          it "adds the uniqueness error" do
         
     | 
| 
       1188 
1138 
     | 
    
         
             
                            login.valid?
         
     | 
| 
       1189 
     | 
    
         
            -
                            login.errors[:username]. 
     | 
| 
      
 1139 
     | 
    
         
            +
                            expect(login.errors[:username]).to eq([ "is already taken" ])
         
     | 
| 
       1190 
1140 
     | 
    
         
             
                          end
         
     | 
| 
       1191 
1141 
     | 
    
         
             
                        end
         
     | 
| 
       1192 
1142 
     | 
    
         | 
| 
         @@ -1197,7 +1147,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1197 
1147 
     | 
    
         
             
                          end
         
     | 
| 
       1198 
1148 
     | 
    
         | 
| 
       1199 
1149 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1200 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1150 
     | 
    
         
            +
                            expect(login).to be_valid
         
     | 
| 
       1201 
1151 
     | 
    
         
             
                          end
         
     | 
| 
       1202 
1152 
     | 
    
         
             
                        end
         
     | 
| 
       1203 
1153 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -1224,7 +1174,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1224 
1174 
     | 
    
         
             
                        end
         
     | 
| 
       1225 
1175 
     | 
    
         | 
| 
       1226 
1176 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1227 
     | 
    
         
            -
                          login. 
     | 
| 
      
 1177 
     | 
    
         
            +
                          expect(login).to be_valid
         
     | 
| 
       1228 
1178 
     | 
    
         
             
                        end
         
     | 
| 
       1229 
1179 
     | 
    
         
             
                      end
         
     | 
| 
       1230 
1180 
     | 
    
         | 
| 
         @@ -1239,7 +1189,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1239 
1189 
     | 
    
         
             
                        end
         
     | 
| 
       1240 
1190 
     | 
    
         | 
| 
       1241 
1191 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1242 
     | 
    
         
            -
                          login. 
     | 
| 
      
 1192 
     | 
    
         
            +
                          expect(login).to be_valid
         
     | 
| 
       1243 
1193 
     | 
    
         
             
                        end
         
     | 
| 
       1244 
1194 
     | 
    
         
             
                      end
         
     | 
| 
       1245 
1195 
     | 
    
         | 
| 
         @@ -1254,7 +1204,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1254 
1204 
     | 
    
         
             
                        end
         
     | 
| 
       1255 
1205 
     | 
    
         | 
| 
       1256 
1206 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1257 
     | 
    
         
            -
                          login. 
     | 
| 
      
 1207 
     | 
    
         
            +
                          expect(login).to be_valid
         
     | 
| 
       1258 
1208 
     | 
    
         
             
                        end
         
     | 
| 
       1259 
1209 
     | 
    
         
             
                      end
         
     | 
| 
       1260 
1210 
     | 
    
         | 
| 
         @@ -1269,7 +1219,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1269 
1219 
     | 
    
         
             
                        end
         
     | 
| 
       1270 
1220 
     | 
    
         | 
| 
       1271 
1221 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1272 
     | 
    
         
            -
                          login. 
     | 
| 
      
 1222 
     | 
    
         
            +
                          expect(login).to be_valid
         
     | 
| 
       1273 
1223 
     | 
    
         
             
                        end
         
     | 
| 
       1274 
1224 
     | 
    
         
             
                      end
         
     | 
| 
       1275 
1225 
     | 
    
         | 
| 
         @@ -1286,12 +1236,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1286 
1236 
     | 
    
         
             
                          end
         
     | 
| 
       1287 
1237 
     | 
    
         | 
| 
       1288 
1238 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       1289 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1239 
     | 
    
         
            +
                            expect(login).to_not be_valid
         
     | 
| 
       1290 
1240 
     | 
    
         
             
                          end
         
     | 
| 
       1291 
1241 
     | 
    
         | 
| 
       1292 
1242 
     | 
    
         
             
                          it "adds the uniqueness errors" do
         
     | 
| 
       1293 
1243 
     | 
    
         
             
                            login.valid?
         
     | 
| 
       1294 
     | 
    
         
            -
                            login.errors[:username]. 
     | 
| 
      
 1244 
     | 
    
         
            +
                            expect(login.errors[:username]).to eq([ "is already taken" ])
         
     | 
| 
       1295 
1245 
     | 
    
         
             
                          end
         
     | 
| 
       1296 
1246 
     | 
    
         
             
                        end
         
     | 
| 
       1297 
1247 
     | 
    
         | 
| 
         @@ -1302,7 +1252,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1302 
1252 
     | 
    
         
             
                          end
         
     | 
| 
       1303 
1253 
     | 
    
         | 
| 
       1304 
1254 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1305 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1255 
     | 
    
         
            +
                            expect(login).to be_valid
         
     | 
| 
       1306 
1256 
     | 
    
         
             
                          end
         
     | 
| 
       1307 
1257 
     | 
    
         
             
                        end
         
     | 
| 
       1308 
1258 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -1329,7 +1279,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1329 
1279 
     | 
    
         
             
                        end
         
     | 
| 
       1330 
1280 
     | 
    
         | 
| 
       1331 
1281 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1332 
     | 
    
         
            -
                          login. 
     | 
| 
      
 1282 
     | 
    
         
            +
                          expect(login).to be_valid
         
     | 
| 
       1333 
1283 
     | 
    
         
             
                        end
         
     | 
| 
       1334 
1284 
     | 
    
         
             
                      end
         
     | 
| 
       1335 
1285 
     | 
    
         | 
| 
         @@ -1346,12 +1296,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1346 
1296 
     | 
    
         
             
                          end
         
     | 
| 
       1347 
1297 
     | 
    
         | 
| 
       1348 
1298 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       1349 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1299 
     | 
    
         
            +
                            expect(login).to_not be_valid
         
     | 
| 
       1350 
1300 
     | 
    
         
             
                          end
         
     | 
| 
       1351 
1301 
     | 
    
         | 
| 
       1352 
1302 
     | 
    
         
             
                          it "adds the uniqueness error" do
         
     | 
| 
       1353 
1303 
     | 
    
         
             
                            login.valid?
         
     | 
| 
       1354 
     | 
    
         
            -
                            login.errors[:username]. 
     | 
| 
      
 1304 
     | 
    
         
            +
                            expect(login.errors[:username]).to eq([ "is already taken" ])
         
     | 
| 
       1355 
1305 
     | 
    
         
             
                          end
         
     | 
| 
       1356 
1306 
     | 
    
         
             
                        end
         
     | 
| 
       1357 
1307 
     | 
    
         | 
| 
         @@ -1362,7 +1312,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1362 
1312 
     | 
    
         
             
                          end
         
     | 
| 
       1363 
1313 
     | 
    
         | 
| 
       1364 
1314 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1365 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1315 
     | 
    
         
            +
                            expect(login).to be_valid
         
     | 
| 
       1366 
1316 
     | 
    
         
             
                          end
         
     | 
| 
       1367 
1317 
     | 
    
         
             
                        end
         
     | 
| 
       1368 
1318 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -1391,7 +1341,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1391 
1341 
     | 
    
         
             
                          end
         
     | 
| 
       1392 
1342 
     | 
    
         | 
| 
       1393 
1343 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1394 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1344 
     | 
    
         
            +
                            expect(login).to be_valid
         
     | 
| 
       1395 
1345 
     | 
    
         
             
                          end
         
     | 
| 
       1396 
1346 
     | 
    
         
             
                        end
         
     | 
| 
       1397 
1347 
     | 
    
         | 
| 
         @@ -1406,7 +1356,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1406 
1356 
     | 
    
         
             
                          end
         
     | 
| 
       1407 
1357 
     | 
    
         | 
| 
       1408 
1358 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1409 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1359 
     | 
    
         
            +
                            expect(login).to be_valid
         
     | 
| 
       1410 
1360 
     | 
    
         
             
                          end
         
     | 
| 
       1411 
1361 
     | 
    
         
             
                        end
         
     | 
| 
       1412 
1362 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -1424,12 +1374,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1424 
1374 
     | 
    
         
             
                          end
         
     | 
| 
       1425 
1375 
     | 
    
         | 
| 
       1426 
1376 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       1427 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1377 
     | 
    
         
            +
                            expect(login).to_not be_valid
         
     | 
| 
       1428 
1378 
     | 
    
         
             
                          end
         
     | 
| 
       1429 
1379 
     | 
    
         | 
| 
       1430 
1380 
     | 
    
         
             
                          it "adds the uniqueness error" do
         
     | 
| 
       1431 
1381 
     | 
    
         
             
                            login.valid?
         
     | 
| 
       1432 
     | 
    
         
            -
                            login.errors[:username]. 
     | 
| 
      
 1382 
     | 
    
         
            +
                            expect(login.errors[:username]).to eq([ "is already taken" ])
         
     | 
| 
       1433 
1383 
     | 
    
         
             
                          end
         
     | 
| 
       1434 
1384 
     | 
    
         
             
                        end
         
     | 
| 
       1435 
1385 
     | 
    
         | 
| 
         @@ -1440,7 +1390,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1440 
1390 
     | 
    
         
             
                          end
         
     | 
| 
       1441 
1391 
     | 
    
         | 
| 
       1442 
1392 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1443 
     | 
    
         
            -
                            login. 
     | 
| 
      
 1393 
     | 
    
         
            +
                            expect(login).to be_valid
         
     | 
| 
       1444 
1394 
     | 
    
         
             
                          end
         
     | 
| 
       1445 
1395 
     | 
    
         
             
                        end
         
     | 
| 
       1446 
1396 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -1467,7 +1417,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1467 
1417 
     | 
    
         
             
                        end
         
     | 
| 
       1468 
1418 
     | 
    
         | 
| 
       1469 
1419 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1470 
     | 
    
         
            -
                          login. 
     | 
| 
      
 1420 
     | 
    
         
            +
                          expect(login).to be_valid
         
     | 
| 
       1471 
1421 
     | 
    
         
             
                        end
         
     | 
| 
       1472 
1422 
     | 
    
         
             
                      end
         
     | 
| 
       1473 
1423 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1493,7 +1443,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1493 
1443 
     | 
    
         
             
                        end
         
     | 
| 
       1494 
1444 
     | 
    
         | 
| 
       1495 
1445 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1496 
     | 
    
         
            -
                          login. 
     | 
| 
      
 1446 
     | 
    
         
            +
                          expect(login).to be_valid
         
     | 
| 
       1497 
1447 
     | 
    
         
             
                        end
         
     | 
| 
       1498 
1448 
     | 
    
         
             
                      end
         
     | 
| 
       1499 
1449 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1540,7 +1490,48 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1540 
1490 
     | 
    
         
             
                      end
         
     | 
| 
       1541 
1491 
     | 
    
         | 
| 
       1542 
1492 
     | 
    
         
             
                    end
         
     | 
| 
      
 1493 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1494 
     | 
    
         
            +
             
     | 
| 
      
 1495 
     | 
    
         
            +
                  context "when conditions is set" do
         
     | 
| 
      
 1496 
     | 
    
         
            +
             
     | 
| 
      
 1497 
     | 
    
         
            +
                    before do
         
     | 
| 
      
 1498 
     | 
    
         
            +
                      Band.validates_uniqueness_of :name, conditions: ->{ Band.where(active: true) }
         
     | 
| 
      
 1499 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1500 
     | 
    
         
            +
             
     | 
| 
      
 1501 
     | 
    
         
            +
                    after do
         
     | 
| 
      
 1502 
     | 
    
         
            +
                      Band.reset_callbacks(:validate)
         
     | 
| 
      
 1503 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1504 
     | 
    
         
            +
             
     | 
| 
      
 1505 
     | 
    
         
            +
                    context "when the attribute is unique" do
         
     | 
| 
      
 1506 
     | 
    
         
            +
             
     | 
| 
      
 1507 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 1508 
     | 
    
         
            +
                        Band.create(name: 'Foo', active: false)
         
     | 
| 
      
 1509 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1510 
     | 
    
         
            +
             
     | 
| 
      
 1511 
     | 
    
         
            +
                      let(:unique_band) do
         
     | 
| 
      
 1512 
     | 
    
         
            +
                        Band.new(name: 'Foo')
         
     | 
| 
      
 1513 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1514 
     | 
    
         
            +
             
     | 
| 
      
 1515 
     | 
    
         
            +
                      it "returns true" do
         
     | 
| 
      
 1516 
     | 
    
         
            +
                        expect(unique_band).to be_valid
         
     | 
| 
      
 1517 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1518 
     | 
    
         
            +
             
     | 
| 
      
 1519 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1520 
     | 
    
         
            +
             
     | 
| 
      
 1521 
     | 
    
         
            +
                    context "when the attribute is not unique" do
         
     | 
| 
      
 1522 
     | 
    
         
            +
             
     | 
| 
      
 1523 
     | 
    
         
            +
                      before do
         
     | 
| 
      
 1524 
     | 
    
         
            +
                        Band.create(name: 'Foo')
         
     | 
| 
      
 1525 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1526 
     | 
    
         
            +
             
     | 
| 
      
 1527 
     | 
    
         
            +
                      let(:non_unique_band) do
         
     | 
| 
      
 1528 
     | 
    
         
            +
                        Band.new(name: 'Foo')
         
     | 
| 
      
 1529 
     | 
    
         
            +
                      end
         
     | 
| 
       1543 
1530 
     | 
    
         | 
| 
      
 1531 
     | 
    
         
            +
                      it "returns false" do
         
     | 
| 
      
 1532 
     | 
    
         
            +
                        expect(non_unique_band).to_not be_valid
         
     | 
| 
      
 1533 
     | 
    
         
            +
                      end
         
     | 
| 
      
 1534 
     | 
    
         
            +
                    end
         
     | 
| 
       1544 
1535 
     | 
    
         
             
                  end
         
     | 
| 
       1545 
1536 
     | 
    
         
             
                end
         
     | 
| 
       1546 
1537 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1587,7 +1578,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1587 
1578 
     | 
    
         
             
                      end
         
     | 
| 
       1588 
1579 
     | 
    
         | 
| 
       1589 
1580 
     | 
    
         
             
                      it "returns true" do
         
     | 
| 
       1590 
     | 
    
         
            -
                        def_two. 
     | 
| 
      
 1581 
     | 
    
         
            +
                        expect(def_two).to be_valid
         
     | 
| 
       1591 
1582 
     | 
    
         
             
                      end
         
     | 
| 
       1592 
1583 
     | 
    
         
             
                    end
         
     | 
| 
       1593 
1584 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1615,7 +1606,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1615 
1606 
     | 
    
         
             
                        end
         
     | 
| 
       1616 
1607 
     | 
    
         | 
| 
       1617 
1608 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1618 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1609 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1619 
1610 
     | 
    
         
             
                        end
         
     | 
| 
       1620 
1611 
     | 
    
         
             
                      end
         
     | 
| 
       1621 
1612 
     | 
    
         | 
| 
         @@ -1632,12 +1623,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1632 
1623 
     | 
    
         
             
                          end
         
     | 
| 
       1633 
1624 
     | 
    
         | 
| 
       1634 
1625 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       1635 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 1626 
     | 
    
         
            +
                            expect(definition).to_not be_valid
         
     | 
| 
       1636 
1627 
     | 
    
         
             
                          end
         
     | 
| 
       1637 
1628 
     | 
    
         | 
| 
       1638 
1629 
     | 
    
         
             
                          it "adds the uniqueness error" do
         
     | 
| 
       1639 
1630 
     | 
    
         
             
                            definition.valid?
         
     | 
| 
       1640 
     | 
    
         
            -
                            definition.errors[:description]. 
     | 
| 
      
 1631 
     | 
    
         
            +
                            expect(definition.errors[:description]).to eq([ "is already taken" ])
         
     | 
| 
       1641 
1632 
     | 
    
         
             
                          end
         
     | 
| 
       1642 
1633 
     | 
    
         
             
                        end
         
     | 
| 
       1643 
1634 
     | 
    
         | 
| 
         @@ -1648,7 +1639,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1648 
1639 
     | 
    
         
             
                          end
         
     | 
| 
       1649 
1640 
     | 
    
         | 
| 
       1650 
1641 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1651 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 1642 
     | 
    
         
            +
                            expect(definition).to be_valid
         
     | 
| 
       1652 
1643 
     | 
    
         
             
                          end
         
     | 
| 
       1653 
1644 
     | 
    
         
             
                        end
         
     | 
| 
       1654 
1645 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -1677,7 +1668,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1677 
1668 
     | 
    
         
             
                        end
         
     | 
| 
       1678 
1669 
     | 
    
         | 
| 
       1679 
1670 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1680 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1671 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1681 
1672 
     | 
    
         
             
                        end
         
     | 
| 
       1682 
1673 
     | 
    
         
             
                      end
         
     | 
| 
       1683 
1674 
     | 
    
         | 
| 
         @@ -1698,7 +1689,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1698 
1689 
     | 
    
         
             
                        end
         
     | 
| 
       1699 
1690 
     | 
    
         | 
| 
       1700 
1691 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1701 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1692 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1702 
1693 
     | 
    
         
             
                        end
         
     | 
| 
       1703 
1694 
     | 
    
         
             
                      end
         
     | 
| 
       1704 
1695 
     | 
    
         | 
| 
         @@ -1716,7 +1707,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1716 
1707 
     | 
    
         
             
                        end
         
     | 
| 
       1717 
1708 
     | 
    
         | 
| 
       1718 
1709 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1719 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1710 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1720 
1711 
     | 
    
         
             
                        end
         
     | 
| 
       1721 
1712 
     | 
    
         
             
                      end
         
     | 
| 
       1722 
1713 
     | 
    
         | 
| 
         @@ -1737,7 +1728,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1737 
1728 
     | 
    
         
             
                        end
         
     | 
| 
       1738 
1729 
     | 
    
         | 
| 
       1739 
1730 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1740 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1731 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1741 
1732 
     | 
    
         
             
                        end
         
     | 
| 
       1742 
1733 
     | 
    
         
             
                      end
         
     | 
| 
       1743 
1734 
     | 
    
         | 
| 
         @@ -1760,12 +1751,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1760 
1751 
     | 
    
         
             
                          end
         
     | 
| 
       1761 
1752 
     | 
    
         | 
| 
       1762 
1753 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       1763 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 1754 
     | 
    
         
            +
                            expect(definition).to_not be_valid
         
     | 
| 
       1764 
1755 
     | 
    
         
             
                          end
         
     | 
| 
       1765 
1756 
     | 
    
         | 
| 
       1766 
1757 
     | 
    
         
             
                          it "adds the uniqueness errors" do
         
     | 
| 
       1767 
1758 
     | 
    
         
             
                            definition.valid?
         
     | 
| 
       1768 
     | 
    
         
            -
                            definition.errors[:description]. 
     | 
| 
      
 1759 
     | 
    
         
            +
                            expect(definition.errors[:description]).to eq([ "is already taken" ])
         
     | 
| 
       1769 
1760 
     | 
    
         
             
                          end
         
     | 
| 
       1770 
1761 
     | 
    
         
             
                        end
         
     | 
| 
       1771 
1762 
     | 
    
         | 
| 
         @@ -1779,7 +1770,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1779 
1770 
     | 
    
         
             
                          end
         
     | 
| 
       1780 
1771 
     | 
    
         | 
| 
       1781 
1772 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1782 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 1773 
     | 
    
         
            +
                            expect(definition).to be_valid
         
     | 
| 
       1783 
1774 
     | 
    
         
             
                          end
         
     | 
| 
       1784 
1775 
     | 
    
         
             
                        end
         
     | 
| 
       1785 
1776 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -1809,7 +1800,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1809 
1800 
     | 
    
         
             
                        end
         
     | 
| 
       1810 
1801 
     | 
    
         | 
| 
       1811 
1802 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1812 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1803 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1813 
1804 
     | 
    
         
             
                        end
         
     | 
| 
       1814 
1805 
     | 
    
         
             
                      end
         
     | 
| 
       1815 
1806 
     | 
    
         | 
| 
         @@ -1832,7 +1823,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1832 
1823 
     | 
    
         
             
                        end
         
     | 
| 
       1833 
1824 
     | 
    
         | 
| 
       1834 
1825 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1835 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1826 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1836 
1827 
     | 
    
         
             
                        end
         
     | 
| 
       1837 
1828 
     | 
    
         
             
                      end
         
     | 
| 
       1838 
1829 
     | 
    
         | 
| 
         @@ -1850,7 +1841,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1850 
1841 
     | 
    
         
             
                        end
         
     | 
| 
       1851 
1842 
     | 
    
         | 
| 
       1852 
1843 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1853 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1844 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1854 
1845 
     | 
    
         
             
                        end
         
     | 
| 
       1855 
1846 
     | 
    
         
             
                      end
         
     | 
| 
       1856 
1847 
     | 
    
         | 
| 
         @@ -1873,7 +1864,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1873 
1864 
     | 
    
         
             
                        end
         
     | 
| 
       1874 
1865 
     | 
    
         | 
| 
       1875 
1866 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1876 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1867 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1877 
1868 
     | 
    
         
             
                        end
         
     | 
| 
       1878 
1869 
     | 
    
         
             
                      end
         
     | 
| 
       1879 
1870 
     | 
    
         | 
| 
         @@ -1898,12 +1889,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1898 
1889 
     | 
    
         
             
                          end
         
     | 
| 
       1899 
1890 
     | 
    
         | 
| 
       1900 
1891 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       1901 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 1892 
     | 
    
         
            +
                            expect(definition).to_not be_valid
         
     | 
| 
       1902 
1893 
     | 
    
         
             
                          end
         
     | 
| 
       1903 
1894 
     | 
    
         | 
| 
       1904 
1895 
     | 
    
         
             
                          it "adds the uniqueness errors" do
         
     | 
| 
       1905 
1896 
     | 
    
         
             
                            definition.valid?
         
     | 
| 
       1906 
     | 
    
         
            -
                            definition.errors[:description]. 
     | 
| 
      
 1897 
     | 
    
         
            +
                            expect(definition.errors[:description]).to eq([ "is already taken" ])
         
     | 
| 
       1907 
1898 
     | 
    
         
             
                          end
         
     | 
| 
       1908 
1899 
     | 
    
         
             
                        end
         
     | 
| 
       1909 
1900 
     | 
    
         | 
| 
         @@ -1918,7 +1909,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1918 
1909 
     | 
    
         
             
                          end
         
     | 
| 
       1919 
1910 
     | 
    
         | 
| 
       1920 
1911 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1921 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 1912 
     | 
    
         
            +
                            expect(definition).to be_valid
         
     | 
| 
       1922 
1913 
     | 
    
         
             
                          end
         
     | 
| 
       1923 
1914 
     | 
    
         
             
                        end
         
     | 
| 
       1924 
1915 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -1945,7 +1936,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1945 
1936 
     | 
    
         
             
                        end
         
     | 
| 
       1946 
1937 
     | 
    
         | 
| 
       1947 
1938 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       1948 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 1939 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       1949 
1940 
     | 
    
         
             
                        end
         
     | 
| 
       1950 
1941 
     | 
    
         
             
                      end
         
     | 
| 
       1951 
1942 
     | 
    
         | 
| 
         @@ -1962,12 +1953,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1962 
1953 
     | 
    
         
             
                          end
         
     | 
| 
       1963 
1954 
     | 
    
         | 
| 
       1964 
1955 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       1965 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 1956 
     | 
    
         
            +
                            expect(definition).to_not be_valid
         
     | 
| 
       1966 
1957 
     | 
    
         
             
                          end
         
     | 
| 
       1967 
1958 
     | 
    
         | 
| 
       1968 
1959 
     | 
    
         
             
                          it "adds the uniqueness error" do
         
     | 
| 
       1969 
1960 
     | 
    
         
             
                            definition.valid?
         
     | 
| 
       1970 
     | 
    
         
            -
                            definition.errors[:description]. 
     | 
| 
      
 1961 
     | 
    
         
            +
                            expect(definition.errors[:description]).to eq([ "is already taken" ])
         
     | 
| 
       1971 
1962 
     | 
    
         
             
                          end
         
     | 
| 
       1972 
1963 
     | 
    
         
             
                        end
         
     | 
| 
       1973 
1964 
     | 
    
         | 
| 
         @@ -1978,7 +1969,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       1978 
1969 
     | 
    
         
             
                          end
         
     | 
| 
       1979 
1970 
     | 
    
         | 
| 
       1980 
1971 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       1981 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 1972 
     | 
    
         
            +
                            expect(definition).to be_valid
         
     | 
| 
       1982 
1973 
     | 
    
         
             
                          end
         
     | 
| 
       1983 
1974 
     | 
    
         
             
                        end
         
     | 
| 
       1984 
1975 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -2007,7 +1998,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2007 
1998 
     | 
    
         
             
                          end
         
     | 
| 
       2008 
1999 
     | 
    
         | 
| 
       2009 
2000 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       2010 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 2001 
     | 
    
         
            +
                            expect(definition).to be_valid
         
     | 
| 
       2011 
2002 
     | 
    
         
             
                          end
         
     | 
| 
       2012 
2003 
     | 
    
         
             
                        end
         
     | 
| 
       2013 
2004 
     | 
    
         | 
| 
         @@ -2022,7 +2013,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2022 
2013 
     | 
    
         
             
                          end
         
     | 
| 
       2023 
2014 
     | 
    
         | 
| 
       2024 
2015 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       2025 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 2016 
     | 
    
         
            +
                            expect(definition).to be_valid
         
     | 
| 
       2026 
2017 
     | 
    
         
             
                          end
         
     | 
| 
       2027 
2018 
     | 
    
         
             
                        end
         
     | 
| 
       2028 
2019 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -2040,12 +2031,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2040 
2031 
     | 
    
         
             
                          end
         
     | 
| 
       2041 
2032 
     | 
    
         | 
| 
       2042 
2033 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       2043 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 2034 
     | 
    
         
            +
                            expect(definition).to_not be_valid
         
     | 
| 
       2044 
2035 
     | 
    
         
             
                          end
         
     | 
| 
       2045 
2036 
     | 
    
         | 
| 
       2046 
2037 
     | 
    
         
             
                          it "adds the uniqueness error" do
         
     | 
| 
       2047 
2038 
     | 
    
         
             
                            definition.valid?
         
     | 
| 
       2048 
     | 
    
         
            -
                            definition.errors[:description]. 
     | 
| 
      
 2039 
     | 
    
         
            +
                            expect(definition.errors[:description]).to eq([ "is already taken" ])
         
     | 
| 
       2049 
2040 
     | 
    
         
             
                          end
         
     | 
| 
       2050 
2041 
     | 
    
         
             
                        end
         
     | 
| 
       2051 
2042 
     | 
    
         | 
| 
         @@ -2056,7 +2047,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2056 
2047 
     | 
    
         
             
                          end
         
     | 
| 
       2057 
2048 
     | 
    
         | 
| 
       2058 
2049 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       2059 
     | 
    
         
            -
                            definition. 
     | 
| 
      
 2050 
     | 
    
         
            +
                            expect(definition).to be_valid
         
     | 
| 
       2060 
2051 
     | 
    
         
             
                          end
         
     | 
| 
       2061 
2052 
     | 
    
         
             
                        end
         
     | 
| 
       2062 
2053 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -2083,7 +2074,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2083 
2074 
     | 
    
         
             
                        end
         
     | 
| 
       2084 
2075 
     | 
    
         | 
| 
       2085 
2076 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       2086 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 2077 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       2087 
2078 
     | 
    
         
             
                        end
         
     | 
| 
       2088 
2079 
     | 
    
         
             
                      end
         
     | 
| 
       2089 
2080 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -2109,7 +2100,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2109 
2100 
     | 
    
         
             
                        end
         
     | 
| 
       2110 
2101 
     | 
    
         | 
| 
       2111 
2102 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       2112 
     | 
    
         
            -
                          definition. 
     | 
| 
      
 2103 
     | 
    
         
            +
                          expect(definition).to be_valid
         
     | 
| 
       2113 
2104 
     | 
    
         
             
                        end
         
     | 
| 
       2114 
2105 
     | 
    
         
             
                      end
         
     | 
| 
       2115 
2106 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -2224,7 +2215,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2224 
2215 
     | 
    
         
             
                        end
         
     | 
| 
       2225 
2216 
     | 
    
         | 
| 
       2226 
2217 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       2227 
     | 
    
         
            -
                          word_origin. 
     | 
| 
      
 2218 
     | 
    
         
            +
                          expect(word_origin).to be_valid
         
     | 
| 
       2228 
2219 
     | 
    
         
             
                        end
         
     | 
| 
       2229 
2220 
     | 
    
         
             
                      end
         
     | 
| 
       2230 
2221 
     | 
    
         | 
| 
         @@ -2241,12 +2232,12 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2241 
2232 
     | 
    
         
             
                          end
         
     | 
| 
       2242 
2233 
     | 
    
         | 
| 
       2243 
2234 
     | 
    
         
             
                          it "returns false" do
         
     | 
| 
       2244 
     | 
    
         
            -
                            word_origin. 
     | 
| 
      
 2235 
     | 
    
         
            +
                            expect(word_origin).to_not be_valid
         
     | 
| 
       2245 
2236 
     | 
    
         
             
                          end
         
     | 
| 
       2246 
2237 
     | 
    
         | 
| 
       2247 
2238 
     | 
    
         
             
                          it "adds the uniqueness error" do
         
     | 
| 
       2248 
2239 
     | 
    
         
             
                            word_origin.valid?
         
     | 
| 
       2249 
     | 
    
         
            -
                            word_origin.errors[:origin_id]. 
     | 
| 
      
 2240 
     | 
    
         
            +
                            expect(word_origin.errors[:origin_id]).to eq([ "is already taken" ])
         
     | 
| 
       2250 
2241 
     | 
    
         
             
                          end
         
     | 
| 
       2251 
2242 
     | 
    
         
             
                        end
         
     | 
| 
       2252 
2243 
     | 
    
         | 
| 
         @@ -2257,7 +2248,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2257 
2248 
     | 
    
         
             
                          end
         
     | 
| 
       2258 
2249 
     | 
    
         | 
| 
       2259 
2250 
     | 
    
         
             
                          it "returns true" do
         
     | 
| 
       2260 
     | 
    
         
            -
                            word_origin. 
     | 
| 
      
 2251 
     | 
    
         
            +
                            expect(word_origin).to be_valid
         
     | 
| 
       2261 
2252 
     | 
    
         
             
                          end
         
     | 
| 
       2262 
2253 
     | 
    
         
             
                        end
         
     | 
| 
       2263 
2254 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -2284,7 +2275,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2284 
2275 
     | 
    
         
             
                        end
         
     | 
| 
       2285 
2276 
     | 
    
         | 
| 
       2286 
2277 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       2287 
     | 
    
         
            -
                          word_origin. 
     | 
| 
      
 2278 
     | 
    
         
            +
                          expect(word_origin).to be_valid
         
     | 
| 
       2288 
2279 
     | 
    
         
             
                        end
         
     | 
| 
       2289 
2280 
     | 
    
         
             
                      end
         
     | 
| 
       2290 
2281 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -2310,7 +2301,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2310 
2301 
     | 
    
         
             
                        end
         
     | 
| 
       2311 
2302 
     | 
    
         | 
| 
       2312 
2303 
     | 
    
         
             
                        it "returns true" do
         
     | 
| 
       2313 
     | 
    
         
            -
                          word_origin. 
     | 
| 
      
 2304 
     | 
    
         
            +
                          expect(word_origin).to be_valid
         
     | 
| 
       2314 
2305 
     | 
    
         
             
                        end
         
     | 
| 
       2315 
2306 
     | 
    
         
             
                      end
         
     | 
| 
       2316 
2307 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -2332,7 +2323,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2332 
2323 
     | 
    
         
             
                  end
         
     | 
| 
       2333 
2324 
     | 
    
         | 
| 
       2334 
2325 
     | 
    
         
             
                  it "always returns true" do
         
     | 
| 
       2335 
     | 
    
         
            -
                    pronunciation. 
     | 
| 
      
 2326 
     | 
    
         
            +
                    expect(pronunciation).to be_valid
         
     | 
| 
       2336 
2327 
     | 
    
         
             
                  end
         
     | 
| 
       2337 
2328 
     | 
    
         
             
                end
         
     | 
| 
       2338 
2329 
     | 
    
         
             
              end
         
     | 
| 
         @@ -2348,29 +2339,30 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2348 
2339 
     | 
    
         
             
                end
         
     | 
| 
       2349 
2340 
     | 
    
         | 
| 
       2350 
2341 
     | 
    
         
             
                it "adds the validation only to the instance" do
         
     | 
| 
       2351 
     | 
    
         
            -
                  validators. 
     | 
| 
      
 2342 
     | 
    
         
            +
                  expect(validators).to eq([ described_class ])
         
     | 
| 
       2352 
2343 
     | 
    
         
             
                end
         
     | 
| 
       2353 
2344 
     | 
    
         
             
              end
         
     | 
| 
       2354 
2345 
     | 
    
         | 
| 
       2355 
2346 
     | 
    
         
             
              context "when validation works with inheritance" do
         
     | 
| 
      
 2347 
     | 
    
         
            +
                class EuropeanActor < Actor
         
     | 
| 
      
 2348 
     | 
    
         
            +
                  validates_uniqueness_of :name
         
     | 
| 
      
 2349 
     | 
    
         
            +
                end
         
     | 
| 
       2356 
2350 
     | 
    
         | 
| 
       2357 
     | 
    
         
            -
                 
     | 
| 
       2358 
     | 
    
         
            -
                  Actor.validates_uniqueness_of :name
         
     | 
| 
       2359 
     | 
    
         
            -
                  Actor.create!(name: "Johnny Depp")
         
     | 
| 
      
 2351 
     | 
    
         
            +
                class SpanishActor < EuropeanActor
         
     | 
| 
       2360 
2352 
     | 
    
         
             
                end
         
     | 
| 
       2361 
2353 
     | 
    
         | 
| 
       2362 
     | 
    
         
            -
                 
     | 
| 
       2363 
     | 
    
         
            -
                   
     | 
| 
      
 2354 
     | 
    
         
            +
                before do
         
     | 
| 
      
 2355 
     | 
    
         
            +
                  EuropeanActor.create!(name: "Antonio Banderas")
         
     | 
| 
       2364 
2356 
     | 
    
         
             
                end
         
     | 
| 
       2365 
2357 
     | 
    
         | 
| 
       2366 
2358 
     | 
    
         
             
                let!(:subclass_document_with_duplicated_name) do
         
     | 
| 
       2367 
     | 
    
         
            -
                   
     | 
| 
      
 2359 
     | 
    
         
            +
                  SpanishActor.new(name: "Antonio Banderas")
         
     | 
| 
       2368 
2360 
     | 
    
         
             
                end
         
     | 
| 
       2369 
2361 
     | 
    
         | 
| 
       2370 
2362 
     | 
    
         
             
                it "should be invalid" do
         
     | 
| 
       2371 
2363 
     | 
    
         
             
                  subclass_document_with_duplicated_name.tap do |d|
         
     | 
| 
       2372 
     | 
    
         
            -
                    d. 
     | 
| 
       2373 
     | 
    
         
            -
                    d.errors[:name]. 
     | 
| 
      
 2364 
     | 
    
         
            +
                    expect(d).to be_invalid
         
     | 
| 
      
 2365 
     | 
    
         
            +
                    expect(d.errors[:name]).to eq([ "is already taken" ])
         
     | 
| 
       2374 
2366 
     | 
    
         
             
                  end
         
     | 
| 
       2375 
2367 
     | 
    
         
             
                end
         
     | 
| 
       2376 
2368 
     | 
    
         
             
              end
         
     | 
| 
         @@ -2383,7 +2375,7 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2383 
2375 
     | 
    
         
             
                end
         
     | 
| 
       2384 
2376 
     | 
    
         | 
| 
       2385 
2377 
     | 
    
         
             
                let!(:person) do
         
     | 
| 
       2386 
     | 
    
         
            -
                  Person.create(ssn: "132-11-1111", username: " 
     | 
| 
      
 2378 
     | 
    
         
            +
                  Person.create(ssn: "132-11-1111", username: "aaasdaffff")
         
     | 
| 
       2387 
2379 
     | 
    
         
             
                end
         
     | 
| 
       2388 
2380 
     | 
    
         | 
| 
       2389 
2381 
     | 
    
         
             
                after do
         
     | 
| 
         @@ -2392,8 +2384,8 @@ describe Mongoid::Validations::UniquenessValidator do 
     | 
|
| 
       2392 
2384 
     | 
    
         | 
| 
       2393 
2385 
     | 
    
         
             
                it "transfers the options to the cloned session" do
         
     | 
| 
       2394 
2386 
     | 
    
         
             
                  expect {
         
     | 
| 
       2395 
     | 
    
         
            -
                    Person. 
     | 
| 
       2396 
     | 
    
         
            -
                  }.to raise_error 
     | 
| 
      
 2387 
     | 
    
         
            +
                    Person.create!(ssn: "132-11-1111", username: "asdfsdfA")
         
     | 
| 
      
 2388 
     | 
    
         
            +
                  }.to raise_error
         
     | 
| 
       2397 
2389 
     | 
    
         
             
                end
         
     | 
| 
       2398 
2390 
     | 
    
         
             
              end
         
     | 
| 
       2399 
2391 
     | 
    
         
             
            end
         
     |