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,15 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            describe Mongoid:: 
     | 
| 
      
 3 
     | 
    
         
            +
            describe Mongoid::Inspectable do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              describe "#inspect" do
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                context "when not allowing dynamic fields" do
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
                  before do
         
     | 
| 
       10 
     | 
    
         
            -
                    Mongoid.configure.allow_dynamic_fields = false
         
     | 
| 
       11 
     | 
    
         
            -
                  end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
9 
     | 
    
         
             
                  let(:person) do
         
     | 
| 
       14 
10 
     | 
    
         
             
                    Person.new(title: "CEO")
         
     | 
| 
       15 
11 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -19,19 +15,19 @@ describe Mongoid::Inspection do 
     | 
|
| 
       19 
15 
     | 
    
         
             
                  end
         
     | 
| 
       20 
16 
     | 
    
         | 
| 
       21 
17 
     | 
    
         
             
                  it "includes the model type" do
         
     | 
| 
       22 
     | 
    
         
            -
                    inspected. 
     | 
| 
      
 18 
     | 
    
         
            +
                    expect(inspected).to include("#<Person")
         
     | 
| 
       23 
19 
     | 
    
         
             
                  end
         
     | 
| 
       24 
20 
     | 
    
         | 
| 
       25 
21 
     | 
    
         
             
                  it "displays the id" do
         
     | 
| 
       26 
     | 
    
         
            -
                    inspected. 
     | 
| 
      
 22 
     | 
    
         
            +
                    expect(inspected).to include("_id: #{person.id}")
         
     | 
| 
       27 
23 
     | 
    
         
             
                  end
         
     | 
| 
       28 
24 
     | 
    
         | 
| 
       29 
25 
     | 
    
         
             
                  it "displays defined fields" do
         
     | 
| 
       30 
     | 
    
         
            -
                    inspected. 
     | 
| 
      
 26 
     | 
    
         
            +
                    expect(inspected).to include("title: \"CEO\"")
         
     | 
| 
       31 
27 
     | 
    
         
             
                  end
         
     | 
| 
       32 
28 
     | 
    
         | 
| 
       33 
29 
     | 
    
         
             
                  it "displays field aliases" do
         
     | 
| 
       34 
     | 
    
         
            -
                    inspected. 
     | 
| 
      
 30 
     | 
    
         
            +
                    expect(inspected).to include("t(test):")
         
     | 
| 
       35 
31 
     | 
    
         
             
                  end
         
     | 
| 
       36 
32 
     | 
    
         
             
                end
         
     | 
| 
       37 
33 
     | 
    
         | 
| 
         @@ -45,12 +41,8 @@ describe Mongoid::Inspection do 
     | 
|
| 
       45 
41 
     | 
    
         
             
                    person.inspect
         
     | 
| 
       46 
42 
     | 
    
         
             
                  end
         
     | 
| 
       47 
43 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
                  before do
         
     | 
| 
       49 
     | 
    
         
            -
                    Mongoid.configure.allow_dynamic_fields = true
         
     | 
| 
       50 
     | 
    
         
            -
                  end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
44 
     | 
    
         
             
                  it "includes dynamic attributes" do
         
     | 
| 
       53 
     | 
    
         
            -
                    inspected. 
     | 
| 
      
 45 
     | 
    
         
            +
                    expect(inspected).to include("some_attribute: \"foo\"")
         
     | 
| 
       54 
46 
     | 
    
         
             
                  end
         
     | 
| 
       55 
47 
     | 
    
         
             
                end
         
     | 
| 
       56 
48 
     | 
    
         
             
              end
         
     | 
| 
         @@ -1,9 +1,9 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "spec_helper"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            describe Mongoid:: 
     | 
| 
      
 3 
     | 
    
         
            +
            describe Mongoid::Interceptable do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              class TestClass
         
     | 
| 
       6 
     | 
    
         
            -
                include Mongoid:: 
     | 
| 
      
 6 
     | 
    
         
            +
                include Mongoid::Interceptable
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                attr_reader :before_save_called, :after_save_called
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
         @@ -23,51 +23,51 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       23 
23 
     | 
    
         
             
                end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                it "includes the before_create callback" do
         
     | 
| 
       26 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 26 
     | 
    
         
            +
                  expect(klass).to respond_to(:before_create)
         
     | 
| 
       27 
27 
     | 
    
         
             
                end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                it "includes the after_create callback" do
         
     | 
| 
       30 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 30 
     | 
    
         
            +
                  expect(klass).to respond_to(:after_create)
         
     | 
| 
       31 
31 
     | 
    
         
             
                end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                it "includes the before_destroy callback" do
         
     | 
| 
       34 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(klass).to respond_to(:before_destroy)
         
     | 
| 
       35 
35 
     | 
    
         
             
                end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                it "includes the after_destroy callback" do
         
     | 
| 
       38 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 38 
     | 
    
         
            +
                  expect(klass).to respond_to(:after_destroy)
         
     | 
| 
       39 
39 
     | 
    
         
             
                end
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                it "includes the before_save callback" do
         
     | 
| 
       42 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 42 
     | 
    
         
            +
                  expect(klass).to respond_to(:before_save)
         
     | 
| 
       43 
43 
     | 
    
         
             
                end
         
     | 
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
                it "includes the after_save callback" do
         
     | 
| 
       46 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 46 
     | 
    
         
            +
                  expect(klass).to respond_to(:after_save)
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
                it "includes the before_update callback" do
         
     | 
| 
       50 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 50 
     | 
    
         
            +
                  expect(klass).to respond_to(:before_update)
         
     | 
| 
       51 
51 
     | 
    
         
             
                end
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
53 
     | 
    
         
             
                it "includes the after_update callback" do
         
     | 
| 
       54 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 54 
     | 
    
         
            +
                  expect(klass).to respond_to(:after_update)
         
     | 
| 
       55 
55 
     | 
    
         
             
                end
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
       57 
57 
     | 
    
         
             
                it "includes the before_validation callback" do
         
     | 
| 
       58 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 58 
     | 
    
         
            +
                  expect(klass).to respond_to(:before_validation)
         
     | 
| 
       59 
59 
     | 
    
         
             
                end
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
61 
     | 
    
         
             
                it "includes the after_validation callback" do
         
     | 
| 
       62 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 62 
     | 
    
         
            +
                  expect(klass).to respond_to(:after_validation)
         
     | 
| 
       63 
63 
     | 
    
         
             
                end
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
65 
     | 
    
         
             
                it "includes the after_initialize callback" do
         
     | 
| 
       66 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 66 
     | 
    
         
            +
                  expect(klass).to respond_to(:after_initialize)
         
     | 
| 
       67 
67 
     | 
    
         
             
                end
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
69 
     | 
    
         
             
                it "includes the after_build callback" do
         
     | 
| 
       70 
     | 
    
         
            -
                  klass. 
     | 
| 
      
 70 
     | 
    
         
            +
                  expect(klass).to respond_to(:after_build)
         
     | 
| 
       71 
71 
     | 
    
         
             
                end
         
     | 
| 
       72 
72 
     | 
    
         
             
              end
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
         @@ -82,7 +82,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       82 
82 
     | 
    
         
             
                  context "when when the document is instantiated" do
         
     | 
| 
       83 
83 
     | 
    
         | 
| 
       84 
84 
     | 
    
         
             
                    it "does not execute the callback" do
         
     | 
| 
       85 
     | 
    
         
            -
                      player.impressions. 
     | 
| 
      
 85 
     | 
    
         
            +
                      expect(player.impressions).to eq(0)
         
     | 
| 
       86 
86 
     | 
    
         
             
                    end
         
     | 
| 
       87 
87 
     | 
    
         
             
                  end
         
     | 
| 
       88 
88 
     | 
    
         | 
| 
         @@ -93,7 +93,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       93 
93 
     | 
    
         
             
                    end
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
                    it "executes the callback" do
         
     | 
| 
       96 
     | 
    
         
            -
                      from_db.impressions. 
     | 
| 
      
 96 
     | 
    
         
            +
                      expect(from_db.impressions).to eq(1)
         
     | 
| 
       97 
97 
     | 
    
         
             
                    end
         
     | 
| 
       98 
98 
     | 
    
         
             
                  end
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
         @@ -104,7 +104,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       104 
104 
     | 
    
         
             
                    end
         
     | 
| 
       105 
105 
     | 
    
         | 
| 
       106 
106 
     | 
    
         
             
                    it "executes the callback" do
         
     | 
| 
       107 
     | 
    
         
            -
                      from_db.impressions. 
     | 
| 
      
 107 
     | 
    
         
            +
                      expect(from_db.impressions).to eq(1)
         
     | 
| 
       108 
108 
     | 
    
         
             
                    end
         
     | 
| 
       109 
109 
     | 
    
         
             
                  end
         
     | 
| 
       110 
110 
     | 
    
         | 
| 
         @@ -119,7 +119,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       119 
119 
     | 
    
         
             
                    end
         
     | 
| 
       120 
120 
     | 
    
         | 
| 
       121 
121 
     | 
    
         
             
                    it "executes the callback" do
         
     | 
| 
       122 
     | 
    
         
            -
                      from_db.impressions. 
     | 
| 
      
 122 
     | 
    
         
            +
                      expect(from_db.impressions).to eq(1)
         
     | 
| 
       123 
123 
     | 
    
         
             
                    end
         
     | 
| 
       124 
124 
     | 
    
         
             
                  end
         
     | 
| 
       125 
125 
     | 
    
         
             
                end
         
     | 
| 
         @@ -133,7 +133,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       133 
133 
     | 
    
         
             
                  context "when when the document is instantiated" do
         
     | 
| 
       134 
134 
     | 
    
         | 
| 
       135 
135 
     | 
    
         
             
                    it "does not execute the callback" do
         
     | 
| 
       136 
     | 
    
         
            -
                      implant.impressions. 
     | 
| 
      
 136 
     | 
    
         
            +
                      expect(implant.impressions).to eq(0)
         
     | 
| 
       137 
137 
     | 
    
         
             
                    end
         
     | 
| 
       138 
138 
     | 
    
         
             
                  end
         
     | 
| 
       139 
139 
     | 
    
         | 
| 
         @@ -144,7 +144,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       144 
144 
     | 
    
         
             
                    end
         
     | 
| 
       145 
145 
     | 
    
         | 
| 
       146 
146 
     | 
    
         
             
                    it "executes the callback" do
         
     | 
| 
       147 
     | 
    
         
            -
                      from_db.impressions. 
     | 
| 
      
 147 
     | 
    
         
            +
                      expect(from_db.impressions).to eq(1)
         
     | 
| 
       148 
148 
     | 
    
         
             
                    end
         
     | 
| 
       149 
149 
     | 
    
         
             
                  end
         
     | 
| 
       150 
150 
     | 
    
         | 
| 
         @@ -155,7 +155,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       155 
155 
     | 
    
         
             
                    end
         
     | 
| 
       156 
156 
     | 
    
         | 
| 
       157 
157 
     | 
    
         
             
                    it "executes the callback" do
         
     | 
| 
       158 
     | 
    
         
            -
                      from_db.impressions. 
     | 
| 
      
 158 
     | 
    
         
            +
                      expect(from_db.impressions).to eq(1)
         
     | 
| 
       159 
159 
     | 
    
         
             
                    end
         
     | 
| 
       160 
160 
     | 
    
         
             
                  end
         
     | 
| 
       161 
161 
     | 
    
         
             
                end
         
     | 
| 
         @@ -168,7 +168,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       168 
168 
     | 
    
         
             
                end
         
     | 
| 
       169 
169 
     | 
    
         | 
| 
       170 
170 
     | 
    
         
             
                it "runs after document instantiation" do
         
     | 
| 
       171 
     | 
    
         
            -
                  game.name. 
     | 
| 
      
 171 
     | 
    
         
            +
                  expect(game.name).to eq("Testing")
         
     | 
| 
       172 
172 
     | 
    
         
             
                end
         
     | 
| 
       173 
173 
     | 
    
         
             
              end
         
     | 
| 
       174 
174 
     | 
    
         | 
| 
         @@ -179,7 +179,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       179 
179 
     | 
    
         
             
                end
         
     | 
| 
       180 
180 
     | 
    
         | 
| 
       181 
181 
     | 
    
         
             
                it "runs after document build (references_many)" do
         
     | 
| 
       182 
     | 
    
         
            -
                  weapon.name. 
     | 
| 
      
 182 
     | 
    
         
            +
                  expect(weapon.name).to eq("Holy Hand Grenade (5)")
         
     | 
| 
       183 
183 
     | 
    
         
             
                end
         
     | 
| 
       184 
184 
     | 
    
         | 
| 
       185 
185 
     | 
    
         
             
                let(:implant) do
         
     | 
| 
         @@ -187,7 +187,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       187 
187 
     | 
    
         
             
                end
         
     | 
| 
       188 
188 
     | 
    
         | 
| 
       189 
189 
     | 
    
         
             
                it "runs after document build (embeds_many)" do
         
     | 
| 
       190 
     | 
    
         
            -
                  implant.name. 
     | 
| 
      
 190 
     | 
    
         
            +
                  expect(implant.name).to eq('Cochlear Implant (5)')
         
     | 
| 
       191 
191 
     | 
    
         
             
                end
         
     | 
| 
       192 
192 
     | 
    
         | 
| 
       193 
193 
     | 
    
         
             
                let(:powerup) do
         
     | 
| 
         @@ -195,7 +195,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       195 
195 
     | 
    
         
             
                end
         
     | 
| 
       196 
196 
     | 
    
         | 
| 
       197 
197 
     | 
    
         
             
                it "runs after document build (references_one)" do
         
     | 
| 
       198 
     | 
    
         
            -
                  powerup.name. 
     | 
| 
      
 198 
     | 
    
         
            +
                  expect(powerup.name).to eq("Quad Damage (5)")
         
     | 
| 
       199 
199 
     | 
    
         
             
                end
         
     | 
| 
       200 
200 
     | 
    
         | 
| 
       201 
201 
     | 
    
         
             
                let(:augmentation) do
         
     | 
| 
         @@ -203,7 +203,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       203 
203 
     | 
    
         
             
                end
         
     | 
| 
       204 
204 
     | 
    
         | 
| 
       205 
205 
     | 
    
         
             
                it "runs after document build (embeds_one)" do
         
     | 
| 
       206 
     | 
    
         
            -
                  augmentation.name. 
     | 
| 
      
 206 
     | 
    
         
            +
                  expect(augmentation.name).to eq("Infolink (5)")
         
     | 
| 
       207 
207 
     | 
    
         
             
                end
         
     | 
| 
       208 
208 
     | 
    
         
             
              end
         
     | 
| 
       209 
209 
     | 
    
         | 
| 
         @@ -216,24 +216,24 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       216 
216 
     | 
    
         
             
                context "callback returns true" do
         
     | 
| 
       217 
217 
     | 
    
         | 
| 
       218 
218 
     | 
    
         
             
                  before do
         
     | 
| 
       219 
     | 
    
         
            -
                    artist. 
     | 
| 
      
 219 
     | 
    
         
            +
                    expect(artist).to receive(:before_create_stub).once.and_return(true)
         
     | 
| 
       220 
220 
     | 
    
         
             
                    artist.save
         
     | 
| 
       221 
221 
     | 
    
         
             
                  end
         
     | 
| 
       222 
222 
     | 
    
         | 
| 
       223 
223 
     | 
    
         
             
                  it "gets saved" do
         
     | 
| 
       224 
     | 
    
         
            -
                    artist.persisted 
     | 
| 
      
 224 
     | 
    
         
            +
                    expect(artist.persisted?).to be true
         
     | 
| 
       225 
225 
     | 
    
         
             
                  end
         
     | 
| 
       226 
226 
     | 
    
         
             
                end
         
     | 
| 
       227 
227 
     | 
    
         | 
| 
       228 
228 
     | 
    
         
             
                context "callback returns false" do
         
     | 
| 
       229 
229 
     | 
    
         | 
| 
       230 
230 
     | 
    
         
             
                  before do
         
     | 
| 
       231 
     | 
    
         
            -
                    artist. 
     | 
| 
      
 231 
     | 
    
         
            +
                    expect(artist).to receive(:before_create_stub).once.and_return(false)
         
     | 
| 
       232 
232 
     | 
    
         
             
                    artist.save
         
     | 
| 
       233 
233 
     | 
    
         
             
                  end
         
     | 
| 
       234 
234 
     | 
    
         | 
| 
       235 
235 
     | 
    
         
             
                  it "does not get saved" do
         
     | 
| 
       236 
     | 
    
         
            -
                    artist.persisted 
     | 
| 
      
 236 
     | 
    
         
            +
                    expect(artist.persisted?).to be false
         
     | 
| 
       237 
237 
     | 
    
         
             
                  end
         
     | 
| 
       238 
238 
     | 
    
         
             
                end
         
     | 
| 
       239 
239 
     | 
    
         
             
              end
         
     | 
| 
         @@ -253,22 +253,22 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       253 
253 
     | 
    
         
             
                  context "when the callback returns true" do
         
     | 
| 
       254 
254 
     | 
    
         | 
| 
       255 
255 
     | 
    
         
             
                    before do
         
     | 
| 
       256 
     | 
    
         
            -
                      artist. 
     | 
| 
      
 256 
     | 
    
         
            +
                      expect(artist).to receive(:before_save_stub).once.and_return(true)
         
     | 
| 
       257 
257 
     | 
    
         
             
                    end
         
     | 
| 
       258 
258 
     | 
    
         | 
| 
       259 
259 
     | 
    
         
             
                    it "the save returns true" do
         
     | 
| 
       260 
     | 
    
         
            -
                      artist.save. 
     | 
| 
      
 260 
     | 
    
         
            +
                      expect(artist.save).to be true
         
     | 
| 
       261 
261 
     | 
    
         
             
                    end
         
     | 
| 
       262 
262 
     | 
    
         
             
                  end
         
     | 
| 
       263 
263 
     | 
    
         | 
| 
       264 
264 
     | 
    
         
             
                  context "when callback returns false" do
         
     | 
| 
       265 
265 
     | 
    
         | 
| 
       266 
266 
     | 
    
         
             
                    before do
         
     | 
| 
       267 
     | 
    
         
            -
                      artist. 
     | 
| 
      
 267 
     | 
    
         
            +
                      expect(artist).to receive(:before_save_stub).once.and_return(false)
         
     | 
| 
       268 
268 
     | 
    
         
             
                    end
         
     | 
| 
       269 
269 
     | 
    
         | 
| 
       270 
270 
     | 
    
         
             
                    it "the save returns false" do
         
     | 
| 
       271 
     | 
    
         
            -
                      artist.save. 
     | 
| 
      
 271 
     | 
    
         
            +
                      expect(artist.save).to be false
         
     | 
| 
       272 
272 
     | 
    
         
             
                    end
         
     | 
| 
       273 
273 
     | 
    
         
             
                  end
         
     | 
| 
       274 
274 
     | 
    
         
             
                end
         
     | 
| 
         @@ -288,22 +288,22 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       288 
288 
     | 
    
         
             
                  context "when the callback returns true" do
         
     | 
| 
       289 
289 
     | 
    
         | 
| 
       290 
290 
     | 
    
         
             
                    before do
         
     | 
| 
       291 
     | 
    
         
            -
                      artist. 
     | 
| 
      
 291 
     | 
    
         
            +
                      expect(artist).to receive(:before_save_stub).once.and_return(true)
         
     | 
| 
       292 
292 
     | 
    
         
             
                    end
         
     | 
| 
       293 
293 
     | 
    
         | 
| 
       294 
294 
     | 
    
         
             
                    it "the save returns true" do
         
     | 
| 
       295 
     | 
    
         
            -
                      artist.save. 
     | 
| 
      
 295 
     | 
    
         
            +
                      expect(artist.save).to be true
         
     | 
| 
       296 
296 
     | 
    
         
             
                    end
         
     | 
| 
       297 
297 
     | 
    
         
             
                  end
         
     | 
| 
       298 
298 
     | 
    
         | 
| 
       299 
299 
     | 
    
         
             
                  context "when the callback returns false" do
         
     | 
| 
       300 
300 
     | 
    
         | 
| 
       301 
301 
     | 
    
         
             
                    before do
         
     | 
| 
       302 
     | 
    
         
            -
                      artist. 
     | 
| 
      
 302 
     | 
    
         
            +
                      expect(artist).to receive(:before_save_stub).once.and_return(false)
         
     | 
| 
       303 
303 
     | 
    
         
             
                    end
         
     | 
| 
       304 
304 
     | 
    
         | 
| 
       305 
305 
     | 
    
         
             
                    it "the save returns false" do
         
     | 
| 
       306 
     | 
    
         
            -
                      artist.save. 
     | 
| 
      
 306 
     | 
    
         
            +
                      expect(artist.save).to be false
         
     | 
| 
       307 
307 
     | 
    
         
             
                    end
         
     | 
| 
       308 
308 
     | 
    
         
             
                  end
         
     | 
| 
       309 
309 
     | 
    
         
             
                end
         
     | 
| 
         @@ -326,22 +326,22 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       326 
326 
     | 
    
         
             
                context "when the callback returns true" do
         
     | 
| 
       327 
327 
     | 
    
         | 
| 
       328 
328 
     | 
    
         
             
                  before do
         
     | 
| 
       329 
     | 
    
         
            -
                    artist. 
     | 
| 
      
 329 
     | 
    
         
            +
                    expect(artist).to receive(:before_destroy_stub).once.and_return(true)
         
     | 
| 
       330 
330 
     | 
    
         
             
                  end
         
     | 
| 
       331 
331 
     | 
    
         | 
| 
       332 
332 
     | 
    
         
             
                  it "the destroy returns true" do
         
     | 
| 
       333 
     | 
    
         
            -
                    artist.destroy. 
     | 
| 
      
 333 
     | 
    
         
            +
                    expect(artist.destroy).to be true
         
     | 
| 
       334 
334 
     | 
    
         
             
                  end
         
     | 
| 
       335 
335 
     | 
    
         
             
                end
         
     | 
| 
       336 
336 
     | 
    
         | 
| 
       337 
337 
     | 
    
         
             
                context "when the callback returns false" do
         
     | 
| 
       338 
338 
     | 
    
         | 
| 
       339 
339 
     | 
    
         
             
                  before do
         
     | 
| 
       340 
     | 
    
         
            -
                    artist. 
     | 
| 
      
 340 
     | 
    
         
            +
                    expect(artist).to receive(:before_destroy_stub).once.and_return(false)
         
     | 
| 
       341 
341 
     | 
    
         
             
                  end
         
     | 
| 
       342 
342 
     | 
    
         | 
| 
       343 
343 
     | 
    
         
             
                  it "the destroy returns false" do
         
     | 
| 
       344 
     | 
    
         
            -
                    artist.destroy. 
     | 
| 
      
 344 
     | 
    
         
            +
                    expect(artist.destroy).to be false
         
     | 
| 
       345 
345 
     | 
    
         
             
                  end
         
     | 
| 
       346 
346 
     | 
    
         
             
                end
         
     | 
| 
       347 
347 
     | 
    
         | 
| 
         @@ -360,7 +360,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       360 
360 
     | 
    
         
             
                  end
         
     | 
| 
       361 
361 
     | 
    
         | 
| 
       362 
362 
     | 
    
         
             
                  it "executes the child destroy callbacks" do
         
     | 
| 
       363 
     | 
    
         
            -
                    record.before_destroy_called. 
     | 
| 
      
 363 
     | 
    
         
            +
                    expect(record.before_destroy_called).to be true
         
     | 
| 
       364 
364 
     | 
    
         
             
                  end
         
     | 
| 
       365 
365 
     | 
    
         
             
                end
         
     | 
| 
       366 
366 
     | 
    
         
             
              end
         
     | 
| 
         @@ -376,11 +376,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       376 
376 
     | 
    
         
             
                end
         
     | 
| 
       377 
377 
     | 
    
         | 
| 
       378 
378 
     | 
    
         
             
                it "runs the after callbacks" do
         
     | 
| 
       379 
     | 
    
         
            -
                  object.after_save_called. 
     | 
| 
      
 379 
     | 
    
         
            +
                  expect(object.after_save_called).to be true
         
     | 
| 
       380 
380 
     | 
    
         
             
                end
         
     | 
| 
       381 
381 
     | 
    
         | 
| 
       382 
382 
     | 
    
         
             
                it "does not run the before callbacks" do
         
     | 
| 
       383 
     | 
    
         
            -
                  object.before_save_called. 
     | 
| 
      
 383 
     | 
    
         
            +
                  expect(object.before_save_called).to be nil
         
     | 
| 
       384 
384 
     | 
    
         
             
                end
         
     | 
| 
       385 
385 
     | 
    
         
             
              end
         
     | 
| 
       386 
386 
     | 
    
         | 
| 
         @@ -395,11 +395,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       395 
395 
     | 
    
         
             
                end
         
     | 
| 
       396 
396 
     | 
    
         | 
| 
       397 
397 
     | 
    
         
             
                it "runs the before callbacks" do
         
     | 
| 
       398 
     | 
    
         
            -
                  object.before_save_called. 
     | 
| 
      
 398 
     | 
    
         
            +
                  expect(object.before_save_called).to be true
         
     | 
| 
       399 
399 
     | 
    
         
             
                end
         
     | 
| 
       400 
400 
     | 
    
         | 
| 
       401 
401 
     | 
    
         
             
                it "does not run the after callbacks" do
         
     | 
| 
       402 
     | 
    
         
            -
                  object.after_save_called. 
     | 
| 
      
 402 
     | 
    
         
            +
                  expect(object.after_save_called).to be nil
         
     | 
| 
       403 
403 
     | 
    
         
             
                end
         
     | 
| 
       404 
404 
     | 
    
         
             
              end
         
     | 
| 
       405 
405 
     | 
    
         | 
| 
         @@ -421,6 +421,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       421 
421 
     | 
    
         | 
| 
       422 
422 
     | 
    
         
             
                      before(:all) do
         
     | 
| 
       423 
423 
     | 
    
         
             
                        Band.define_model_callbacks(:rearrange)
         
     | 
| 
      
 424 
     | 
    
         
            +
                        Band.after_rearrange { }
         
     | 
| 
       424 
425 
     | 
    
         
             
                      end
         
     | 
| 
       425 
426 
     | 
    
         | 
| 
       426 
427 
     | 
    
         
             
                      after(:all) do
         
     | 
| 
         @@ -428,7 +429,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       428 
429 
     | 
    
         
             
                      end
         
     | 
| 
       429 
430 
     | 
    
         | 
| 
       430 
431 
     | 
    
         
             
                      it "does not cascade to the child" do
         
     | 
| 
       431 
     | 
    
         
            -
                        band.run_callbacks(:rearrange). 
     | 
| 
      
 432 
     | 
    
         
            +
                        expect(band.run_callbacks(:rearrange)).to be true
         
     | 
| 
       432 
433 
     | 
    
         
             
                      end
         
     | 
| 
       433 
434 
     | 
    
         
             
                    end
         
     | 
| 
       434 
435 
     | 
    
         | 
| 
         @@ -455,7 +456,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       455 
456 
     | 
    
         | 
| 
       456 
457 
     | 
    
         
             
                      it "does not cascade to the child" do
         
     | 
| 
       457 
458 
     | 
    
         
             
                        Band.accepts_nested_attributes_for :records, allow_destroy: true
         
     | 
| 
       458 
     | 
    
         
            -
                        band.update_attributes(attributes). 
     | 
| 
      
 459 
     | 
    
         
            +
                        expect(band.update_attributes(attributes)).to be true
         
     | 
| 
       459 
460 
     | 
    
         
             
                      end
         
     | 
| 
       460 
461 
     | 
    
         
             
                    end
         
     | 
| 
       461 
462 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -485,7 +486,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       485 
486 
     | 
    
         
             
                    context "when saving the root" do
         
     | 
| 
       486 
487 
     | 
    
         | 
| 
       487 
488 
     | 
    
         
             
                      it "only executes the callbacks once for each embed" do
         
     | 
| 
       488 
     | 
    
         
            -
                        note. 
     | 
| 
      
 489 
     | 
    
         
            +
                        expect(note).to receive(:update_saved).twice
         
     | 
| 
       489 
490 
     | 
    
         
             
                        band.save
         
     | 
| 
       490 
491 
     | 
    
         
             
                      end
         
     | 
| 
       491 
492 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -503,8 +504,8 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       503 
504 
     | 
    
         
             
                  end
         
     | 
| 
       504 
505 
     | 
    
         | 
| 
       505 
506 
     | 
    
         
             
                  it "doesn't cascade the initialize" do
         
     | 
| 
       506 
     | 
    
         
            -
                    Service. 
     | 
| 
       507 
     | 
    
         
            -
                    Person.find(person.id). 
     | 
| 
      
 507 
     | 
    
         
            +
                    expect_any_instance_of(Service).to receive(:after_initialize_called=).never
         
     | 
| 
      
 508 
     | 
    
         
            +
                    expect(Person.find(person.id)).to eq(person)
         
     | 
| 
       508 
509 
     | 
    
         
             
                  end
         
     | 
| 
       509 
510 
     | 
    
         
             
                end
         
     | 
| 
       510 
511 
     | 
    
         | 
| 
         @@ -538,7 +539,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       538 
539 
     | 
    
         
             
                        end
         
     | 
| 
       539 
540 
     | 
    
         | 
| 
       540 
541 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       541 
     | 
    
         
            -
                          label.after_create_called. 
     | 
| 
      
 542 
     | 
    
         
            +
                          expect(label.after_create_called).to be true
         
     | 
| 
       542 
543 
     | 
    
         
             
                        end
         
     | 
| 
       543 
544 
     | 
    
         
             
                      end
         
     | 
| 
       544 
545 
     | 
    
         | 
| 
         @@ -557,7 +558,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       557 
558 
     | 
    
         
             
                        end
         
     | 
| 
       558 
559 
     | 
    
         | 
| 
       559 
560 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       560 
     | 
    
         
            -
                          label.after_create_called. 
     | 
| 
      
 561 
     | 
    
         
            +
                          expect(label.after_create_called).to be true
         
     | 
| 
       561 
562 
     | 
    
         
             
                        end
         
     | 
| 
       562 
563 
     | 
    
         
             
                      end
         
     | 
| 
       563 
564 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -578,7 +579,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       578 
579 
     | 
    
         
             
                      end
         
     | 
| 
       579 
580 
     | 
    
         | 
| 
       580 
581 
     | 
    
         
             
                      it "does not execute the callback" do
         
     | 
| 
       581 
     | 
    
         
            -
                        label.after_create_called. 
     | 
| 
      
 582 
     | 
    
         
            +
                        expect(label.after_create_called).to be false
         
     | 
| 
       582 
583 
     | 
    
         
             
                      end
         
     | 
| 
       583 
584 
     | 
    
         
             
                    end
         
     | 
| 
       584 
585 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -602,7 +603,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       602 
603 
     | 
    
         
             
                        end
         
     | 
| 
       603 
604 
     | 
    
         | 
| 
       604 
605 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       605 
     | 
    
         
            -
                          label.after_save_called. 
     | 
| 
      
 606 
     | 
    
         
            +
                          expect(label.after_save_called).to be true
         
     | 
| 
       606 
607 
     | 
    
         
             
                        end
         
     | 
| 
       607 
608 
     | 
    
         
             
                      end
         
     | 
| 
       608 
609 
     | 
    
         | 
| 
         @@ -621,7 +622,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       621 
622 
     | 
    
         
             
                        end
         
     | 
| 
       622 
623 
     | 
    
         | 
| 
       623 
624 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       624 
     | 
    
         
            -
                          label.after_save_called. 
     | 
| 
      
 625 
     | 
    
         
            +
                          expect(label.after_save_called).to be true
         
     | 
| 
       625 
626 
     | 
    
         
             
                        end
         
     | 
| 
       626 
627 
     | 
    
         
             
                      end
         
     | 
| 
       627 
628 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -641,7 +642,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       641 
642 
     | 
    
         
             
                      end
         
     | 
| 
       642 
643 
     | 
    
         | 
| 
       643 
644 
     | 
    
         
             
                      it "executes the callback" do
         
     | 
| 
       644 
     | 
    
         
            -
                        label.after_save_called. 
     | 
| 
      
 645 
     | 
    
         
            +
                        expect(label.after_save_called).to be true
         
     | 
| 
       645 
646 
     | 
    
         
             
                      end
         
     | 
| 
       646 
647 
     | 
    
         
             
                    end
         
     | 
| 
       647 
648 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -665,7 +666,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       665 
666 
     | 
    
         
             
                        end
         
     | 
| 
       666 
667 
     | 
    
         | 
| 
       667 
668 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       668 
     | 
    
         
            -
                          label.after_update_called. 
     | 
| 
      
 669 
     | 
    
         
            +
                          expect(label.after_update_called).to be false
         
     | 
| 
       669 
670 
     | 
    
         
             
                        end
         
     | 
| 
       670 
671 
     | 
    
         
             
                      end
         
     | 
| 
       671 
672 
     | 
    
         | 
| 
         @@ -684,7 +685,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       684 
685 
     | 
    
         
             
                        end
         
     | 
| 
       685 
686 
     | 
    
         | 
| 
       686 
687 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       687 
     | 
    
         
            -
                          label.after_update_called. 
     | 
| 
      
 688 
     | 
    
         
            +
                          expect(label.after_update_called).to be false
         
     | 
| 
       688 
689 
     | 
    
         
             
                        end
         
     | 
| 
       689 
690 
     | 
    
         
             
                      end
         
     | 
| 
       690 
691 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -707,7 +708,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       707 
708 
     | 
    
         
             
                        end
         
     | 
| 
       708 
709 
     | 
    
         | 
| 
       709 
710 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       710 
     | 
    
         
            -
                          label.after_update_called. 
     | 
| 
      
 711 
     | 
    
         
            +
                          expect(label.after_update_called).to be true
         
     | 
| 
       711 
712 
     | 
    
         
             
                        end
         
     | 
| 
       712 
713 
     | 
    
         
             
                      end
         
     | 
| 
       713 
714 
     | 
    
         | 
| 
         @@ -722,7 +723,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       722 
723 
     | 
    
         
             
                        end
         
     | 
| 
       723 
724 
     | 
    
         | 
| 
       724 
725 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       725 
     | 
    
         
            -
                          label.after_update_called. 
     | 
| 
      
 726 
     | 
    
         
            +
                          expect(label.after_update_called).to be false
         
     | 
| 
       726 
727 
     | 
    
         
             
                        end
         
     | 
| 
       727 
728 
     | 
    
         
             
                      end
         
     | 
| 
       728 
729 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -747,7 +748,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       747 
748 
     | 
    
         
             
                        end
         
     | 
| 
       748 
749 
     | 
    
         | 
| 
       749 
750 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       750 
     | 
    
         
            -
                          label.after_validation_called. 
     | 
| 
      
 751 
     | 
    
         
            +
                          expect(label.after_validation_called).to be true
         
     | 
| 
       751 
752 
     | 
    
         
             
                        end
         
     | 
| 
       752 
753 
     | 
    
         
             
                      end
         
     | 
| 
       753 
754 
     | 
    
         | 
| 
         @@ -766,7 +767,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       766 
767 
     | 
    
         
             
                        end
         
     | 
| 
       767 
768 
     | 
    
         | 
| 
       768 
769 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       769 
     | 
    
         
            -
                          label.after_validation_called. 
     | 
| 
      
 770 
     | 
    
         
            +
                          expect(label.after_validation_called).to be true
         
     | 
| 
       770 
771 
     | 
    
         
             
                        end
         
     | 
| 
       771 
772 
     | 
    
         
             
                      end
         
     | 
| 
       772 
773 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -786,7 +787,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       786 
787 
     | 
    
         
             
                      end
         
     | 
| 
       787 
788 
     | 
    
         | 
| 
       788 
789 
     | 
    
         
             
                      it "executes the callback" do
         
     | 
| 
       789 
     | 
    
         
            -
                        label.after_validation_called. 
     | 
| 
      
 790 
     | 
    
         
            +
                        expect(label.after_validation_called).to be true
         
     | 
| 
       790 
791 
     | 
    
         
             
                      end
         
     | 
| 
       791 
792 
     | 
    
         
             
                    end
         
     | 
| 
       792 
793 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -810,7 +811,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       810 
811 
     | 
    
         
             
                        end
         
     | 
| 
       811 
812 
     | 
    
         | 
| 
       812 
813 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       813 
     | 
    
         
            -
                          record.before_create_called. 
     | 
| 
      
 814 
     | 
    
         
            +
                          expect(record.before_create_called).to be true
         
     | 
| 
       814 
815 
     | 
    
         
             
                        end
         
     | 
| 
       815 
816 
     | 
    
         
             
                      end
         
     | 
| 
       816 
817 
     | 
    
         | 
| 
         @@ -829,7 +830,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       829 
830 
     | 
    
         
             
                        end
         
     | 
| 
       830 
831 
     | 
    
         | 
| 
       831 
832 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       832 
     | 
    
         
            -
                          record.before_create_called. 
     | 
| 
      
 833 
     | 
    
         
            +
                          expect(record.before_create_called).to be true
         
     | 
| 
       833 
834 
     | 
    
         
             
                        end
         
     | 
| 
       834 
835 
     | 
    
         
             
                      end
         
     | 
| 
       835 
836 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -850,7 +851,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       850 
851 
     | 
    
         
             
                      end
         
     | 
| 
       851 
852 
     | 
    
         | 
| 
       852 
853 
     | 
    
         
             
                      it "does not execute the callback" do
         
     | 
| 
       853 
     | 
    
         
            -
                        record.before_create_called. 
     | 
| 
      
 854 
     | 
    
         
            +
                        expect(record.before_create_called).to be false
         
     | 
| 
       854 
855 
     | 
    
         
             
                      end
         
     | 
| 
       855 
856 
     | 
    
         
             
                    end
         
     | 
| 
       856 
857 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -874,11 +875,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       874 
875 
     | 
    
         
             
                        end
         
     | 
| 
       875 
876 
     | 
    
         | 
| 
       876 
877 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       877 
     | 
    
         
            -
                          record.before_save_called. 
     | 
| 
      
 878 
     | 
    
         
            +
                          expect(record.before_save_called).to be true
         
     | 
| 
       878 
879 
     | 
    
         
             
                        end
         
     | 
| 
       879 
880 
     | 
    
         | 
| 
       880 
881 
     | 
    
         
             
                        it "persists the change" do
         
     | 
| 
       881 
     | 
    
         
            -
                          band.reload.records.first.before_save_called. 
     | 
| 
      
 882 
     | 
    
         
            +
                          expect(band.reload.records.first.before_save_called).to be true
         
     | 
| 
       882 
883 
     | 
    
         
             
                        end
         
     | 
| 
       883 
884 
     | 
    
         
             
                      end
         
     | 
| 
       884 
885 
     | 
    
         | 
| 
         @@ -897,11 +898,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       897 
898 
     | 
    
         
             
                        end
         
     | 
| 
       898 
899 
     | 
    
         | 
| 
       899 
900 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       900 
     | 
    
         
            -
                          record.before_save_called. 
     | 
| 
      
 901 
     | 
    
         
            +
                          expect(record.before_save_called).to be true
         
     | 
| 
       901 
902 
     | 
    
         
             
                        end
         
     | 
| 
       902 
903 
     | 
    
         | 
| 
       903 
904 
     | 
    
         
             
                        it "persists the change" do
         
     | 
| 
       904 
     | 
    
         
            -
                          band.reload.records.first.before_save_called. 
     | 
| 
      
 905 
     | 
    
         
            +
                          expect(band.reload.records.first.before_save_called).to be true
         
     | 
| 
       905 
906 
     | 
    
         
             
                        end
         
     | 
| 
       906 
907 
     | 
    
         
             
                      end
         
     | 
| 
       907 
908 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -921,11 +922,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       921 
922 
     | 
    
         
             
                      end
         
     | 
| 
       922 
923 
     | 
    
         | 
| 
       923 
924 
     | 
    
         
             
                      it "executes the callback" do
         
     | 
| 
       924 
     | 
    
         
            -
                        record.before_save_called. 
     | 
| 
      
 925 
     | 
    
         
            +
                        expect(record.before_save_called).to be true
         
     | 
| 
       925 
926 
     | 
    
         
             
                      end
         
     | 
| 
       926 
927 
     | 
    
         | 
| 
       927 
928 
     | 
    
         
             
                      it "persists the change" do
         
     | 
| 
       928 
     | 
    
         
            -
                        band.reload.records.first.before_save_called. 
     | 
| 
      
 929 
     | 
    
         
            +
                        expect(band.reload.records.first.before_save_called).to be true
         
     | 
| 
       929 
930 
     | 
    
         
             
                      end
         
     | 
| 
       930 
931 
     | 
    
         
             
                    end
         
     | 
| 
       931 
932 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -949,7 +950,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       949 
950 
     | 
    
         
             
                        end
         
     | 
| 
       950 
951 
     | 
    
         | 
| 
       951 
952 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       952 
     | 
    
         
            -
                          record.before_update_called. 
     | 
| 
      
 953 
     | 
    
         
            +
                          expect(record.before_update_called).to be false
         
     | 
| 
       953 
954 
     | 
    
         
             
                        end
         
     | 
| 
       954 
955 
     | 
    
         
             
                      end
         
     | 
| 
       955 
956 
     | 
    
         | 
| 
         @@ -968,7 +969,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       968 
969 
     | 
    
         
             
                        end
         
     | 
| 
       969 
970 
     | 
    
         | 
| 
       970 
971 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       971 
     | 
    
         
            -
                          record.before_update_called. 
     | 
| 
      
 972 
     | 
    
         
            +
                          expect(record.before_update_called).to be false
         
     | 
| 
       972 
973 
     | 
    
         
             
                        end
         
     | 
| 
       973 
974 
     | 
    
         
             
                      end
         
     | 
| 
       974 
975 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -991,11 +992,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       991 
992 
     | 
    
         
             
                        end
         
     | 
| 
       992 
993 
     | 
    
         | 
| 
       993 
994 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       994 
     | 
    
         
            -
                          record.before_update_called. 
     | 
| 
      
 995 
     | 
    
         
            +
                          expect(record.before_update_called).to be true
         
     | 
| 
       995 
996 
     | 
    
         
             
                        end
         
     | 
| 
       996 
997 
     | 
    
         | 
| 
       997 
998 
     | 
    
         
             
                        it "persists the change" do
         
     | 
| 
       998 
     | 
    
         
            -
                          band.reload.records.first.before_update_called. 
     | 
| 
      
 999 
     | 
    
         
            +
                          expect(band.reload.records.first.before_update_called).to be true
         
     | 
| 
       999 
1000 
     | 
    
         
             
                        end
         
     | 
| 
       1000 
1001 
     | 
    
         
             
                      end
         
     | 
| 
       1001 
1002 
     | 
    
         | 
| 
         @@ -1006,7 +1007,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1006 
1007 
     | 
    
         
             
                        end
         
     | 
| 
       1007 
1008 
     | 
    
         | 
| 
       1008 
1009 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       1009 
     | 
    
         
            -
                          record.before_update_called. 
     | 
| 
      
 1010 
     | 
    
         
            +
                          expect(record.before_update_called).to be false
         
     | 
| 
       1010 
1011 
     | 
    
         
             
                        end
         
     | 
| 
       1011 
1012 
     | 
    
         
             
                      end
         
     | 
| 
       1012 
1013 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1031,11 +1032,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1031 
1032 
     | 
    
         
             
                        end
         
     | 
| 
       1032 
1033 
     | 
    
         | 
| 
       1033 
1034 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1034 
     | 
    
         
            -
                          record.before_validation_called. 
     | 
| 
      
 1035 
     | 
    
         
            +
                          expect(record.before_validation_called).to be true
         
     | 
| 
       1035 
1036 
     | 
    
         
             
                        end
         
     | 
| 
       1036 
1037 
     | 
    
         | 
| 
       1037 
1038 
     | 
    
         
             
                        it "persists the change" do
         
     | 
| 
       1038 
     | 
    
         
            -
                          band.reload.records.first.before_validation_called. 
     | 
| 
      
 1039 
     | 
    
         
            +
                          expect(band.reload.records.first.before_validation_called).to be true
         
     | 
| 
       1039 
1040 
     | 
    
         
             
                        end
         
     | 
| 
       1040 
1041 
     | 
    
         
             
                      end
         
     | 
| 
       1041 
1042 
     | 
    
         | 
| 
         @@ -1054,11 +1055,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1054 
1055 
     | 
    
         
             
                        end
         
     | 
| 
       1055 
1056 
     | 
    
         | 
| 
       1056 
1057 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1057 
     | 
    
         
            -
                          record.before_validation_called. 
     | 
| 
      
 1058 
     | 
    
         
            +
                          expect(record.before_validation_called).to be true
         
     | 
| 
       1058 
1059 
     | 
    
         
             
                        end
         
     | 
| 
       1059 
1060 
     | 
    
         | 
| 
       1060 
1061 
     | 
    
         
             
                        it "persists the change" do
         
     | 
| 
       1061 
     | 
    
         
            -
                          band.reload.records.first.before_validation_called. 
     | 
| 
      
 1062 
     | 
    
         
            +
                          expect(band.reload.records.first.before_validation_called).to be true
         
     | 
| 
       1062 
1063 
     | 
    
         
             
                        end
         
     | 
| 
       1063 
1064 
     | 
    
         
             
                      end
         
     | 
| 
       1064 
1065 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1078,11 +1079,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1078 
1079 
     | 
    
         
             
                      end
         
     | 
| 
       1079 
1080 
     | 
    
         | 
| 
       1080 
1081 
     | 
    
         
             
                      it "executes the callback" do
         
     | 
| 
       1081 
     | 
    
         
            -
                        record.before_validation_called. 
     | 
| 
      
 1082 
     | 
    
         
            +
                        expect(record.before_validation_called).to be true
         
     | 
| 
       1082 
1083 
     | 
    
         
             
                      end
         
     | 
| 
       1083 
1084 
     | 
    
         | 
| 
       1084 
1085 
     | 
    
         
             
                      it "persists the change" do
         
     | 
| 
       1085 
     | 
    
         
            -
                        band.reload.records.first.before_validation_called. 
     | 
| 
      
 1086 
     | 
    
         
            +
                        expect(band.reload.records.first.before_validation_called).to be true
         
     | 
| 
       1086 
1087 
     | 
    
         
             
                      end
         
     | 
| 
       1087 
1088 
     | 
    
         
             
                    end
         
     | 
| 
       1088 
1089 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1113,7 +1114,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1113 
1114 
     | 
    
         
             
                        end
         
     | 
| 
       1114 
1115 
     | 
    
         | 
| 
       1115 
1116 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1116 
     | 
    
         
            -
                          track.before_create_called. 
     | 
| 
      
 1117 
     | 
    
         
            +
                          expect(track.before_create_called).to be true
         
     | 
| 
       1117 
1118 
     | 
    
         
             
                        end
         
     | 
| 
       1118 
1119 
     | 
    
         
             
                      end
         
     | 
| 
       1119 
1120 
     | 
    
         | 
| 
         @@ -1136,7 +1137,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1136 
1137 
     | 
    
         
             
                        end
         
     | 
| 
       1137 
1138 
     | 
    
         | 
| 
       1138 
1139 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1139 
     | 
    
         
            -
                          track.before_create_called. 
     | 
| 
      
 1140 
     | 
    
         
            +
                          expect(track.before_create_called).to be true
         
     | 
| 
       1140 
1141 
     | 
    
         
             
                        end
         
     | 
| 
       1141 
1142 
     | 
    
         
             
                      end
         
     | 
| 
       1142 
1143 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1161,7 +1162,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1161 
1162 
     | 
    
         
             
                      end
         
     | 
| 
       1162 
1163 
     | 
    
         | 
| 
       1163 
1164 
     | 
    
         
             
                      it "does not execute the callback" do
         
     | 
| 
       1164 
     | 
    
         
            -
                        track.before_create_called. 
     | 
| 
      
 1165 
     | 
    
         
            +
                        expect(track.before_create_called).to be false
         
     | 
| 
       1165 
1166 
     | 
    
         
             
                      end
         
     | 
| 
       1166 
1167 
     | 
    
         
             
                    end
         
     | 
| 
       1167 
1168 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1193,11 +1194,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1193 
1194 
     | 
    
         
             
                        end
         
     | 
| 
       1194 
1195 
     | 
    
         | 
| 
       1195 
1196 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1196 
     | 
    
         
            -
                          track.before_save_called. 
     | 
| 
      
 1197 
     | 
    
         
            +
                          expect(track.before_save_called).to be true
         
     | 
| 
       1197 
1198 
     | 
    
         
             
                        end
         
     | 
| 
       1198 
1199 
     | 
    
         | 
| 
       1199 
1200 
     | 
    
         
             
                        it "persists the change" do
         
     | 
| 
       1200 
     | 
    
         
            -
                          reloaded.tracks.first.before_save_called. 
     | 
| 
      
 1201 
     | 
    
         
            +
                          expect(reloaded.tracks.first.before_save_called).to be true
         
     | 
| 
       1201 
1202 
     | 
    
         
             
                        end
         
     | 
| 
       1202 
1203 
     | 
    
         
             
                      end
         
     | 
| 
       1203 
1204 
     | 
    
         | 
| 
         @@ -1224,11 +1225,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1224 
1225 
     | 
    
         
             
                        end
         
     | 
| 
       1225 
1226 
     | 
    
         | 
| 
       1226 
1227 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1227 
     | 
    
         
            -
                          track.before_save_called. 
     | 
| 
      
 1228 
     | 
    
         
            +
                          expect(track.before_save_called).to be true
         
     | 
| 
       1228 
1229 
     | 
    
         
             
                        end
         
     | 
| 
       1229 
1230 
     | 
    
         | 
| 
       1230 
1231 
     | 
    
         
             
                        it "persists the change" do
         
     | 
| 
       1231 
     | 
    
         
            -
                          reloaded.tracks.first.before_save_called. 
     | 
| 
      
 1232 
     | 
    
         
            +
                          expect(reloaded.tracks.first.before_save_called).to be true
         
     | 
| 
       1232 
1233 
     | 
    
         
             
                        end
         
     | 
| 
       1233 
1234 
     | 
    
         
             
                      end
         
     | 
| 
       1234 
1235 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1256,11 +1257,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1256 
1257 
     | 
    
         
             
                      end
         
     | 
| 
       1257 
1258 
     | 
    
         | 
| 
       1258 
1259 
     | 
    
         
             
                      it "executes the callback" do
         
     | 
| 
       1259 
     | 
    
         
            -
                        track.before_save_called. 
     | 
| 
      
 1260 
     | 
    
         
            +
                        expect(track.before_save_called).to be true
         
     | 
| 
       1260 
1261 
     | 
    
         
             
                      end
         
     | 
| 
       1261 
1262 
     | 
    
         | 
| 
       1262 
1263 
     | 
    
         
             
                      it "persists the change" do
         
     | 
| 
       1263 
     | 
    
         
            -
                        reloaded.tracks.first.before_save_called. 
     | 
| 
      
 1264 
     | 
    
         
            +
                        expect(reloaded.tracks.first.before_save_called).to be true
         
     | 
| 
       1264 
1265 
     | 
    
         
             
                      end
         
     | 
| 
       1265 
1266 
     | 
    
         
             
                    end
         
     | 
| 
       1266 
1267 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1288,7 +1289,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1288 
1289 
     | 
    
         
             
                        end
         
     | 
| 
       1289 
1290 
     | 
    
         | 
| 
       1290 
1291 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       1291 
     | 
    
         
            -
                          track.before_update_called. 
     | 
| 
      
 1292 
     | 
    
         
            +
                          expect(track.before_update_called).to be false
         
     | 
| 
       1292 
1293 
     | 
    
         
             
                        end
         
     | 
| 
       1293 
1294 
     | 
    
         
             
                      end
         
     | 
| 
       1294 
1295 
     | 
    
         | 
| 
         @@ -1311,7 +1312,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1311 
1312 
     | 
    
         
             
                        end
         
     | 
| 
       1312 
1313 
     | 
    
         | 
| 
       1313 
1314 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       1314 
     | 
    
         
            -
                          track.before_update_called. 
     | 
| 
      
 1315 
     | 
    
         
            +
                          expect(track.before_update_called).to be false
         
     | 
| 
       1315 
1316 
     | 
    
         
             
                        end
         
     | 
| 
       1316 
1317 
     | 
    
         
             
                      end
         
     | 
| 
       1317 
1318 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1342,11 +1343,11 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1342 
1343 
     | 
    
         
             
                        end
         
     | 
| 
       1343 
1344 
     | 
    
         | 
| 
       1344 
1345 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1345 
     | 
    
         
            -
                          track.before_update_called. 
     | 
| 
      
 1346 
     | 
    
         
            +
                          expect(track.before_update_called).to be true
         
     | 
| 
       1346 
1347 
     | 
    
         
             
                        end
         
     | 
| 
       1347 
1348 
     | 
    
         | 
| 
       1348 
1349 
     | 
    
         
             
                        it "persists the change" do
         
     | 
| 
       1349 
     | 
    
         
            -
                          reloaded.tracks.first.before_update_called. 
     | 
| 
      
 1350 
     | 
    
         
            +
                          expect(reloaded.tracks.first.before_update_called).to be true
         
     | 
| 
       1350 
1351 
     | 
    
         
             
                        end
         
     | 
| 
       1351 
1352 
     | 
    
         
             
                      end
         
     | 
| 
       1352 
1353 
     | 
    
         | 
| 
         @@ -1357,7 +1358,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1357 
1358 
     | 
    
         
             
                        end
         
     | 
| 
       1358 
1359 
     | 
    
         | 
| 
       1359 
1360 
     | 
    
         
             
                        it "does not execute the callback" do
         
     | 
| 
       1360 
     | 
    
         
            -
                          track.before_update_called. 
     | 
| 
      
 1361 
     | 
    
         
            +
                          expect(track.before_update_called).to be false
         
     | 
| 
       1361 
1362 
     | 
    
         
             
                        end
         
     | 
| 
       1362 
1363 
     | 
    
         
             
                      end
         
     | 
| 
       1363 
1364 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1386,7 +1387,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1386 
1387 
     | 
    
         
             
                        end
         
     | 
| 
       1387 
1388 
     | 
    
         | 
| 
       1388 
1389 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1389 
     | 
    
         
            -
                          track.before_validation_called. 
     | 
| 
      
 1390 
     | 
    
         
            +
                          expect(track.before_validation_called).to be true
         
     | 
| 
       1390 
1391 
     | 
    
         
             
                        end
         
     | 
| 
       1391 
1392 
     | 
    
         
             
                      end
         
     | 
| 
       1392 
1393 
     | 
    
         | 
| 
         @@ -1409,7 +1410,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1409 
1410 
     | 
    
         
             
                        end
         
     | 
| 
       1410 
1411 
     | 
    
         | 
| 
       1411 
1412 
     | 
    
         
             
                        it "executes the callback" do
         
     | 
| 
       1412 
     | 
    
         
            -
                          track.before_validation_called. 
     | 
| 
      
 1413 
     | 
    
         
            +
                          expect(track.before_validation_called).to be true
         
     | 
| 
       1413 
1414 
     | 
    
         
             
                        end
         
     | 
| 
       1414 
1415 
     | 
    
         
             
                      end
         
     | 
| 
       1415 
1416 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1433,7 +1434,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1433 
1434 
     | 
    
         
             
                      end
         
     | 
| 
       1434 
1435 
     | 
    
         | 
| 
       1435 
1436 
     | 
    
         
             
                      it "executes the callback" do
         
     | 
| 
       1436 
     | 
    
         
            -
                        track.before_validation_called. 
     | 
| 
      
 1437 
     | 
    
         
            +
                        expect(track.before_validation_called).to be true
         
     | 
| 
       1437 
1438 
     | 
    
         
             
                      end
         
     | 
| 
       1438 
1439 
     | 
    
         
             
                    end
         
     | 
| 
       1439 
1440 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -1445,7 +1446,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1445 
1446 
     | 
    
         
             
                it "goes in all validation callback in good order" do
         
     | 
| 
       1446 
1447 
     | 
    
         
             
                  shin = ValidationCallback.new
         
     | 
| 
       1447 
1448 
     | 
    
         
             
                  shin.valid?
         
     | 
| 
       1448 
     | 
    
         
            -
                  shin.history. 
     | 
| 
      
 1449 
     | 
    
         
            +
                  expect(shin.history).to eq([:before_validation, :validate, :after_validation])
         
     | 
| 
       1449 
1450 
     | 
    
         
             
                end
         
     | 
| 
       1450 
1451 
     | 
    
         
             
              end
         
     | 
| 
       1451 
1452 
     | 
    
         | 
| 
         @@ -1460,8 +1461,8 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1460 
1461 
     | 
    
         
             
                end
         
     | 
| 
       1461 
1462 
     | 
    
         | 
| 
       1462 
1463 
     | 
    
         
             
                it "does not duplicate the child documents" do
         
     | 
| 
       1463 
     | 
    
         
            -
                  parent. 
     | 
| 
       1464 
     | 
    
         
            -
                  ParentDoc.find(parent.id). 
     | 
| 
      
 1464 
     | 
    
         
            +
                  parent.children.create(position: 1)
         
     | 
| 
      
 1465 
     | 
    
         
            +
                  expect(ParentDoc.find(parent.id).children.size).to eq(1)
         
     | 
| 
       1465 
1466 
     | 
    
         
             
                end
         
     | 
| 
       1466 
1467 
     | 
    
         
             
              end
         
     | 
| 
       1467 
1468 
     | 
    
         | 
| 
         @@ -1488,22 +1489,22 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1488 
1489 
     | 
    
         
             
                  end
         
     | 
| 
       1489 
1490 
     | 
    
         | 
| 
       1490 
1491 
     | 
    
         
             
                  it "fails to save" do
         
     | 
| 
       1491 
     | 
    
         
            -
                    person. 
     | 
| 
       1492 
     | 
    
         
            -
                    person.save. 
     | 
| 
      
 1492 
     | 
    
         
            +
                    expect(person).to be_valid
         
     | 
| 
      
 1493 
     | 
    
         
            +
                    expect(person.save).to be false
         
     | 
| 
       1493 
1494 
     | 
    
         
             
                  end
         
     | 
| 
       1494 
1495 
     | 
    
         | 
| 
       1495 
1496 
     | 
    
         
             
                  it "is a new record" do
         
     | 
| 
       1496 
     | 
    
         
            -
                    person. 
     | 
| 
      
 1497 
     | 
    
         
            +
                    expect(person).to be_a_new_record
         
     | 
| 
       1497 
1498 
     | 
    
         
             
                    expect { person.save }.not_to change { person.new_record? }
         
     | 
| 
       1498 
1499 
     | 
    
         
             
                  end
         
     | 
| 
       1499 
1500 
     | 
    
         | 
| 
       1500 
1501 
     | 
    
         
             
                  it "is left dirty" do
         
     | 
| 
       1501 
     | 
    
         
            -
                    person. 
     | 
| 
      
 1502 
     | 
    
         
            +
                    expect(person).to be_changed
         
     | 
| 
       1502 
1503 
     | 
    
         
             
                    expect { person.save }.not_to change { person.changed? }
         
     | 
| 
       1503 
1504 
     | 
    
         
             
                  end
         
     | 
| 
       1504 
1505 
     | 
    
         | 
| 
       1505 
1506 
     | 
    
         
             
                  it "child documents are left dirty" do
         
     | 
| 
       1506 
     | 
    
         
            -
                    address. 
     | 
| 
      
 1507 
     | 
    
         
            +
                    expect(address).to be_changed
         
     | 
| 
       1507 
1508 
     | 
    
         
             
                    expect { person.save }.not_to change { address.changed? }
         
     | 
| 
       1508 
1509 
     | 
    
         
             
                  end
         
     | 
| 
       1509 
1510 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1521,22 +1522,22 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1521 
1522 
     | 
    
         
             
                  end
         
     | 
| 
       1522 
1523 
     | 
    
         | 
| 
       1523 
1524 
     | 
    
         
             
                  it "#save returns false" do
         
     | 
| 
       1524 
     | 
    
         
            -
                    person. 
     | 
| 
       1525 
     | 
    
         
            -
                    person.save. 
     | 
| 
      
 1525 
     | 
    
         
            +
                    expect(person).to be_valid
         
     | 
| 
      
 1526 
     | 
    
         
            +
                    expect(person.save).to be false
         
     | 
| 
       1526 
1527 
     | 
    
         
             
                  end
         
     | 
| 
       1527 
1528 
     | 
    
         | 
| 
       1528 
1529 
     | 
    
         
             
                  it "is a not a new record" do
         
     | 
| 
       1529 
     | 
    
         
            -
                    person. 
     | 
| 
      
 1530 
     | 
    
         
            +
                    expect(person).to_not be_a_new_record
         
     | 
| 
       1530 
1531 
     | 
    
         
             
                    expect { person.save }.not_to change { person.new_record? }
         
     | 
| 
       1531 
1532 
     | 
    
         
             
                  end
         
     | 
| 
       1532 
1533 
     | 
    
         | 
| 
       1533 
1534 
     | 
    
         
             
                  it "is left dirty" do
         
     | 
| 
       1534 
     | 
    
         
            -
                    person. 
     | 
| 
      
 1535 
     | 
    
         
            +
                    expect(person).to be_changed
         
     | 
| 
       1535 
1536 
     | 
    
         
             
                    expect { person.save }.not_to change { person.changed? }
         
     | 
| 
       1536 
1537 
     | 
    
         
             
                  end
         
     | 
| 
       1537 
1538 
     | 
    
         | 
| 
       1538 
1539 
     | 
    
         
             
                  it "child documents are left dirty" do
         
     | 
| 
       1539 
     | 
    
         
            -
                    address. 
     | 
| 
      
 1540 
     | 
    
         
            +
                    expect(address).to be_changed
         
     | 
| 
       1540 
1541 
     | 
    
         
             
                    expect { person.save }.not_to change { address.changed? }
         
     | 
| 
       1541 
1542 
     | 
    
         
             
                  end
         
     | 
| 
       1542 
1543 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1556,7 +1557,7 @@ describe Mongoid::Callbacks do 
     | 
|
| 
       1556 
1557 
     | 
    
         
             
                context "when saving the document" do
         
     | 
| 
       1557 
1558 
     | 
    
         | 
| 
       1558 
1559 
     | 
    
         
             
                  it "only executes the callbacks once" do
         
     | 
| 
       1559 
     | 
    
         
            -
                    callback. 
     | 
| 
      
 1560 
     | 
    
         
            +
                    expect(callback).to receive(:execute).once
         
     | 
| 
       1560 
1561 
     | 
    
         
             
                    callback.save
         
     | 
| 
       1561 
1562 
     | 
    
         
             
                  end
         
     | 
| 
       1562 
1563 
     | 
    
         
             
                end
         
     |