mongoid 8.0.9 → 8.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +3 -3
- data/README.md +3 -3
- data/Rakefile +18 -67
- data/lib/config/locales/en.yml +46 -14
- data/lib/mongoid/association/accessors.rb +3 -7
- data/lib/mongoid/association/builders.rb +1 -1
- data/lib/mongoid/association/eager_loadable.rb +0 -3
- data/lib/mongoid/association/embedded/batchable.rb +2 -2
- data/lib/mongoid/association/embedded/embedded_in/buildable.rb +2 -2
- data/lib/mongoid/association/embedded/embedded_in/proxy.rb +2 -1
- data/lib/mongoid/association/embedded/embeds_many/buildable.rb +3 -2
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +6 -6
- data/lib/mongoid/association/embedded/embeds_one/buildable.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_one/proxy.rb +1 -1
- data/lib/mongoid/association/macros.rb +0 -6
- data/lib/mongoid/association/nested/one.rb +40 -2
- data/lib/mongoid/association/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/counter_cache.rb +2 -2
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +2 -2
- data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
- data/lib/mongoid/association/reflections.rb +2 -2
- data/lib/mongoid/atomic.rb +7 -16
- data/lib/mongoid/attributes/dynamic.rb +1 -1
- data/lib/mongoid/attributes/nested.rb +2 -2
- data/lib/mongoid/attributes/processing.rb +5 -29
- data/lib/mongoid/attributes/projector.rb +1 -1
- data/lib/mongoid/attributes/readonly.rb +1 -1
- data/lib/mongoid/attributes.rb +8 -2
- data/lib/mongoid/changeable.rb +107 -5
- data/lib/mongoid/clients/storage_options.rb +2 -5
- data/lib/mongoid/clients/validators/storage.rb +1 -13
- data/lib/mongoid/collection_configurable.rb +58 -0
- data/lib/mongoid/composable.rb +2 -0
- data/lib/mongoid/config/defaults.rb +60 -0
- data/lib/mongoid/config/options.rb +0 -3
- data/lib/mongoid/config/validators/async_query_executor.rb +24 -0
- data/lib/mongoid/config/validators.rb +1 -0
- data/lib/mongoid/config.rb +88 -27
- data/lib/mongoid/contextual/atomic.rb +1 -1
- data/lib/mongoid/contextual/memory.rb +233 -33
- data/lib/mongoid/contextual/mongo/documents_loader.rb +177 -0
- data/lib/mongoid/contextual/mongo.rb +370 -133
- data/lib/mongoid/contextual/none.rb +162 -7
- data/lib/mongoid/contextual.rb +12 -0
- data/lib/mongoid/criteria/findable.rb +2 -2
- data/lib/mongoid/criteria/includable.rb +4 -3
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -15
- data/lib/mongoid/criteria/queryable/key.rb +1 -1
- data/lib/mongoid/criteria/queryable/mergeable.rb +1 -1
- data/lib/mongoid/criteria/queryable/optional.rb +8 -8
- data/lib/mongoid/criteria/queryable/selectable.rb +43 -12
- data/lib/mongoid/criteria/queryable/selector.rb +1 -1
- data/lib/mongoid/criteria/queryable/storable.rb +1 -1
- data/lib/mongoid/criteria.rb +6 -5
- data/lib/mongoid/deprecable.rb +1 -2
- data/lib/mongoid/deprecation.rb +3 -3
- data/lib/mongoid/document.rb +1 -8
- data/lib/mongoid/errors/create_collection_failure.rb +33 -0
- data/lib/mongoid/errors/drop_collection_failure.rb +27 -0
- data/lib/mongoid/errors/immutable_attribute.rb +26 -0
- data/lib/mongoid/errors/invalid_async_query_executor.rb +25 -0
- data/lib/mongoid/errors/invalid_global_executor_concurrency.rb +22 -0
- data/lib/mongoid/errors/invalid_storage_parent.rb +2 -0
- data/lib/mongoid/errors.rb +4 -1
- data/lib/mongoid/extensions/hash.rb +2 -24
- data/lib/mongoid/extensions/object.rb +2 -2
- data/lib/mongoid/extensions/time.rb +2 -0
- data/lib/mongoid/fields/localized.rb +10 -0
- data/lib/mongoid/fields/standard.rb +10 -0
- data/lib/mongoid/fields.rb +59 -35
- data/lib/mongoid/findable.rb +27 -3
- data/lib/mongoid/interceptable.rb +6 -116
- data/lib/mongoid/matcher/eq_impl.rb +1 -1
- data/lib/mongoid/matcher/type.rb +1 -1
- data/lib/mongoid/persistable/creatable.rb +1 -0
- data/lib/mongoid/persistable/deletable.rb +1 -1
- data/lib/mongoid/persistable/savable.rb +13 -1
- data/lib/mongoid/persistable/unsettable.rb +2 -2
- data/lib/mongoid/persistable/updatable.rb +51 -1
- data/lib/mongoid/persistable/upsertable.rb +20 -1
- data/lib/mongoid/persistable.rb +3 -0
- data/lib/mongoid/query_cache.rb +5 -1
- data/lib/mongoid/railties/database.rake +7 -2
- data/lib/mongoid/reloadable.rb +5 -3
- data/lib/mongoid/stateful.rb +22 -1
- data/lib/mongoid/tasks/database.rake +12 -0
- data/lib/mongoid/tasks/database.rb +20 -0
- data/lib/mongoid/timestamps/created.rb +1 -8
- data/lib/mongoid/traversable.rb +0 -12
- data/lib/mongoid/utils.rb +22 -0
- data/lib/mongoid/validatable/associated.rb +17 -98
- data/lib/mongoid/validatable/macros.rb +5 -5
- data/lib/mongoid/validatable.rb +4 -9
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid/warnings.rb +17 -1
- data/lib/mongoid.rb +16 -3
- data/spec/integration/app_spec.rb +2 -2
- data/spec/integration/associations/has_and_belongs_to_many_spec.rb +0 -40
- data/spec/integration/callbacks_spec.rb +99 -12
- data/spec/integration/discriminator_key_spec.rb +4 -5
- data/spec/integration/i18n_fallbacks_spec.rb +3 -2
- data/spec/mongoid/association/eager_spec.rb +2 -24
- data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +27 -0
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +20 -25
- data/spec/mongoid/association/embedded/embeds_many_models.rb +1 -0
- data/spec/mongoid/association/embedded/embeds_many_query_spec.rb +0 -4
- data/spec/mongoid/association/embedded/embeds_one/proxy_spec.rb +15 -2
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +2 -18
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +5 -27
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +9 -50
- data/spec/mongoid/association/syncable_spec.rb +1 -1
- data/spec/mongoid/association_spec.rb +0 -60
- data/spec/mongoid/attributes_spec.rb +3 -33
- data/spec/mongoid/changeable_spec.rb +299 -24
- data/spec/mongoid/clients_spec.rb +122 -13
- data/spec/mongoid/collection_configurable_spec.rb +158 -0
- data/spec/mongoid/config/defaults_spec.rb +160 -0
- data/spec/mongoid/config_spec.rb +154 -27
- data/spec/mongoid/contextual/memory_spec.rb +332 -76
- data/spec/mongoid/contextual/mongo/documents_loader_spec.rb +187 -0
- data/spec/mongoid/contextual/mongo_spec.rb +1009 -125
- data/spec/mongoid/contextual/none_spec.rb +49 -2
- data/spec/mongoid/copyable_spec.rb +2 -10
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +4 -10
- data/spec/mongoid/criteria/queryable/options_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +419 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/selector_spec.rb +3 -76
- data/spec/mongoid/criteria/queryable/storable_spec.rb +0 -72
- data/spec/mongoid/criteria_projection_spec.rb +1 -4
- data/spec/mongoid/criteria_spec.rb +5 -9
- data/spec/mongoid/document_spec.rb +0 -27
- data/spec/mongoid/errors/readonly_document_spec.rb +2 -2
- data/spec/mongoid/extensions/hash_spec.rb +3 -3
- data/spec/mongoid/extensions/time_spec.rb +8 -43
- data/spec/mongoid/extensions/time_with_zone_spec.rb +7 -52
- data/spec/mongoid/fields/localized_spec.rb +46 -28
- data/spec/mongoid/fields_spec.rb +136 -77
- data/spec/mongoid/findable_spec.rb +391 -34
- data/spec/mongoid/indexable_spec.rb +16 -10
- data/spec/mongoid/interceptable_spec.rb +153 -442
- data/spec/mongoid/interceptable_spec_models.rb +111 -51
- data/spec/mongoid/persistable/deletable_spec.rb +26 -6
- data/spec/mongoid/persistable/destroyable_spec.rb +26 -6
- data/spec/mongoid/persistable/incrementable_spec.rb +37 -0
- data/spec/mongoid/persistable/logical_spec.rb +37 -0
- data/spec/mongoid/persistable/poppable_spec.rb +36 -0
- data/spec/mongoid/persistable/pullable_spec.rb +72 -0
- data/spec/mongoid/persistable/pushable_spec.rb +72 -0
- data/spec/mongoid/persistable/renamable_spec.rb +36 -0
- data/spec/mongoid/persistable/savable_spec.rb +96 -0
- data/spec/mongoid/persistable/settable_spec.rb +37 -0
- data/spec/mongoid/persistable/unsettable_spec.rb +36 -0
- data/spec/mongoid/persistable/updatable_spec.rb +20 -28
- data/spec/mongoid/persistable/upsertable_spec.rb +80 -6
- data/spec/mongoid/persistence_context_spec.rb +7 -57
- data/spec/mongoid/query_cache_spec.rb +56 -61
- data/spec/mongoid/reloadable_spec.rb +24 -28
- data/spec/mongoid/scopable_spec.rb +70 -0
- data/spec/mongoid/serializable_spec.rb +23 -44
- data/spec/mongoid/stateful_spec.rb +122 -8
- data/spec/mongoid/tasks/database_rake_spec.rb +74 -0
- data/spec/mongoid/tasks/database_spec.rb +127 -0
- data/spec/mongoid/timestamps/created_spec.rb +0 -23
- data/spec/mongoid/timestamps_spec.rb +9 -11
- data/spec/mongoid/touchable_spec.rb +277 -5
- data/spec/mongoid/touchable_spec_models.rb +3 -1
- data/spec/mongoid/traversable_spec.rb +9 -24
- data/spec/mongoid/validatable/associated_spec.rb +34 -27
- data/spec/mongoid/validatable/uniqueness_spec.rb +2 -3
- data/spec/mongoid_spec.rb +36 -10
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/bin/s3-copy +45 -0
- data/spec/shared/bin/s3-upload +69 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +231 -0
- data/spec/shared/lib/mrss/constraints.rb +378 -0
- data/spec/shared/lib/mrss/docker_runner.rb +298 -0
- data/spec/shared/lib/mrss/eg_config_utils.rb +51 -0
- data/spec/shared/lib/mrss/event_subscriber.rb +210 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +238 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +113 -0
- data/spec/shared/lib/mrss/session_registry.rb +69 -0
- data/spec/shared/lib/mrss/session_registry_legacy.rb +60 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +179 -0
- data/spec/shared/lib/mrss/utils.rb +37 -0
- data/spec/shared/share/Dockerfile.erb +321 -0
- data/spec/shared/share/haproxy-1.conf +16 -0
- data/spec/shared/share/haproxy-2.conf +17 -0
- data/spec/shared/shlib/config.sh +27 -0
- data/spec/shared/shlib/distro.sh +74 -0
- data/spec/shared/shlib/server.sh +416 -0
- data/spec/shared/shlib/set_env.sh +169 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/immutable_ids.rb +118 -0
- data/spec/support/macros.rb +47 -15
- data/spec/support/models/artist.rb +0 -1
- data/spec/support/models/band.rb +1 -0
- data/spec/support/models/book.rb +1 -0
- data/spec/support/models/building.rb +2 -0
- data/spec/support/models/cover.rb +10 -0
- data/spec/support/models/name.rb +0 -10
- data/spec/support/models/person.rb +0 -1
- data/spec/support/models/product.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +746 -636
- metadata.gz.sig +2 -0
- data/spec/mongoid/criteria/queryable/extensions/bignum_spec.rb +0 -60
- data/spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb +0 -60
- data/spec/support/models/purse.rb +0 -9
@@ -388,86 +388,6 @@ describe Mongoid::Interceptable do
|
|
388
388
|
end
|
389
389
|
end
|
390
390
|
end
|
391
|
-
|
392
|
-
context 'with embedded grandchildren' do
|
393
|
-
IS = InterceptableSpec
|
394
|
-
|
395
|
-
config_override :prevent_multiple_calls_of_embedded_callbacks, true
|
396
|
-
|
397
|
-
context 'when creating' do
|
398
|
-
let(:registry) { IS::CallbackRegistry.new(only: %i[ before_save ]) }
|
399
|
-
|
400
|
-
let(:expected_calls) do
|
401
|
-
[
|
402
|
-
# the parent
|
403
|
-
[ IS::CbParent, :before_save ],
|
404
|
-
|
405
|
-
# the immediate child of the parent
|
406
|
-
[ IS::CbCascadedNode, :before_save ],
|
407
|
-
|
408
|
-
# the grandchild of the parent
|
409
|
-
[ IS::CbCascadedNode, :before_save ],
|
410
|
-
]
|
411
|
-
end
|
412
|
-
|
413
|
-
let!(:parent) do
|
414
|
-
parent = IS::CbParent.new(registry)
|
415
|
-
child = IS::CbCascadedNode.new(registry)
|
416
|
-
grandchild = IS::CbCascadedNode.new(registry)
|
417
|
-
|
418
|
-
child.cb_cascaded_nodes = [ grandchild ]
|
419
|
-
parent.cb_cascaded_nodes = [ child ]
|
420
|
-
|
421
|
-
parent.tap(&:save)
|
422
|
-
end
|
423
|
-
|
424
|
-
it 'should cascade callbacks to grandchildren' do
|
425
|
-
expect(registry.calls).to be == expected_calls
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
context 'when updating' do
|
430
|
-
let(:registry) { IS::CallbackRegistry.new(only: %i[ before_update ]) }
|
431
|
-
|
432
|
-
let(:expected_calls) do
|
433
|
-
[
|
434
|
-
# the parent
|
435
|
-
[ IS::CbParent, :before_update ],
|
436
|
-
|
437
|
-
# the immediate child of the parent
|
438
|
-
[ IS::CbCascadedNode, :before_update ],
|
439
|
-
|
440
|
-
# the grandchild of the parent
|
441
|
-
[ IS::CbCascadedNode, :before_update ],
|
442
|
-
]
|
443
|
-
end
|
444
|
-
|
445
|
-
let!(:parent) do
|
446
|
-
parent = IS::CbParent.new(nil)
|
447
|
-
child = IS::CbCascadedNode.new(nil)
|
448
|
-
grandchild = IS::CbCascadedNode.new(nil)
|
449
|
-
|
450
|
-
child.cb_cascaded_nodes = [ grandchild ]
|
451
|
-
parent.cb_cascaded_nodes = [ child ]
|
452
|
-
|
453
|
-
parent.save
|
454
|
-
|
455
|
-
parent.callback_registry = registry
|
456
|
-
child.callback_registry = registry
|
457
|
-
grandchild.callback_registry = registry
|
458
|
-
|
459
|
-
parent.name = 'updated'
|
460
|
-
child.name = 'updated'
|
461
|
-
grandchild.name = 'updated'
|
462
|
-
|
463
|
-
parent.tap(&:save)
|
464
|
-
end
|
465
|
-
|
466
|
-
it 'should cascade callbacks to grandchildren' do
|
467
|
-
expect(registry.calls).to be == expected_calls
|
468
|
-
end
|
469
|
-
end
|
470
|
-
end
|
471
391
|
end
|
472
392
|
|
473
393
|
describe ".before_destroy" do
|
@@ -1863,80 +1783,40 @@ describe Mongoid::Interceptable do
|
|
1863
1783
|
end
|
1864
1784
|
end
|
1865
1785
|
|
1866
|
-
|
1867
|
-
|
1786
|
+
let(:expected) do
|
1787
|
+
[
|
1788
|
+
[InterceptableSpec::CbCascadedChild, :before_validation],
|
1789
|
+
[InterceptableSpec::CbCascadedChild, :after_validation],
|
1790
|
+
[InterceptableSpec::CbParent, :before_validation],
|
1791
|
+
[InterceptableSpec::CbCascadedChild, :before_validation],
|
1792
|
+
[InterceptableSpec::CbCascadedChild, :after_validation],
|
1868
1793
|
|
1869
|
-
|
1870
|
-
[
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
[InterceptableSpec::CbCascadedChild, :before_validation],
|
1875
|
-
[InterceptableSpec::CbCascadedChild, :after_validation],
|
1876
|
-
|
1877
|
-
[InterceptableSpec::CbParent, :after_validation],
|
1878
|
-
[InterceptableSpec::CbParent, :before_save],
|
1879
|
-
[InterceptableSpec::CbParent, :around_save_open],
|
1880
|
-
[InterceptableSpec::CbParent, :before_create],
|
1881
|
-
[InterceptableSpec::CbParent, :around_create_open],
|
1882
|
-
|
1883
|
-
[InterceptableSpec::CbCascadedChild, :before_save],
|
1884
|
-
[InterceptableSpec::CbCascadedChild, :around_save_open],
|
1885
|
-
[InterceptableSpec::CbCascadedChild, :before_create],
|
1886
|
-
[InterceptableSpec::CbCascadedChild, :around_create_open],
|
1887
|
-
|
1888
|
-
[InterceptableSpec::CbCascadedChild, :around_create_close],
|
1889
|
-
[InterceptableSpec::CbCascadedChild, :after_create],
|
1890
|
-
[InterceptableSpec::CbCascadedChild, :around_save_close],
|
1891
|
-
[InterceptableSpec::CbCascadedChild, :after_save],
|
1892
|
-
|
1893
|
-
[InterceptableSpec::CbParent, :around_create_close],
|
1894
|
-
[InterceptableSpec::CbParent, :after_create],
|
1895
|
-
[InterceptableSpec::CbParent, :around_save_close],
|
1896
|
-
[InterceptableSpec::CbParent, :after_save]
|
1897
|
-
]
|
1898
|
-
end
|
1794
|
+
[InterceptableSpec::CbParent, :after_validation],
|
1795
|
+
[InterceptableSpec::CbParent, :before_save],
|
1796
|
+
[InterceptableSpec::CbParent, :around_save_open],
|
1797
|
+
[InterceptableSpec::CbParent, :before_create],
|
1798
|
+
[InterceptableSpec::CbParent, :around_create_open],
|
1899
1799
|
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
end
|
1800
|
+
[InterceptableSpec::CbCascadedChild, :before_save],
|
1801
|
+
[InterceptableSpec::CbCascadedChild, :around_save_open],
|
1802
|
+
[InterceptableSpec::CbCascadedChild, :before_create],
|
1803
|
+
[InterceptableSpec::CbCascadedChild, :around_create_open],
|
1905
1804
|
|
1906
|
-
|
1907
|
-
|
1805
|
+
[InterceptableSpec::CbCascadedChild, :around_create_close],
|
1806
|
+
[InterceptableSpec::CbCascadedChild, :after_create],
|
1807
|
+
[InterceptableSpec::CbCascadedChild, :around_save_close],
|
1808
|
+
[InterceptableSpec::CbCascadedChild, :after_save],
|
1908
1809
|
|
1909
|
-
|
1910
|
-
[
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
[InterceptableSpec::CbCascadedChild, :after_validation],
|
1916
|
-
|
1917
|
-
[InterceptableSpec::CbParent, :after_validation],
|
1918
|
-
[InterceptableSpec::CbParent, :before_save],
|
1919
|
-
[InterceptableSpec::CbParent, :around_save_open],
|
1920
|
-
[InterceptableSpec::CbParent, :before_create],
|
1921
|
-
[InterceptableSpec::CbParent, :around_create_open],
|
1922
|
-
|
1923
|
-
[InterceptableSpec::CbCascadedChild, :before_save],
|
1924
|
-
[InterceptableSpec::CbCascadedChild, :before_create],
|
1925
|
-
|
1926
|
-
[InterceptableSpec::CbCascadedChild, :after_create],
|
1927
|
-
[InterceptableSpec::CbCascadedChild, :after_save],
|
1928
|
-
|
1929
|
-
[InterceptableSpec::CbParent, :around_create_close],
|
1930
|
-
[InterceptableSpec::CbParent, :after_create],
|
1931
|
-
[InterceptableSpec::CbParent, :around_save_close],
|
1932
|
-
[InterceptableSpec::CbParent, :after_save]
|
1933
|
-
]
|
1934
|
-
end
|
1810
|
+
[InterceptableSpec::CbParent, :around_create_close],
|
1811
|
+
[InterceptableSpec::CbParent, :after_create],
|
1812
|
+
[InterceptableSpec::CbParent, :around_save_close],
|
1813
|
+
[InterceptableSpec::CbParent, :after_save]
|
1814
|
+
]
|
1815
|
+
end
|
1935
1816
|
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
end
|
1817
|
+
it 'calls callbacks in the right order' do
|
1818
|
+
parent.save!
|
1819
|
+
expect(registry.calls).to eq expected
|
1940
1820
|
end
|
1941
1821
|
end
|
1942
1822
|
|
@@ -1999,180 +1879,89 @@ describe Mongoid::Interceptable do
|
|
1999
1879
|
end
|
2000
1880
|
|
2001
1881
|
context "create" do
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
[
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_save_close],
|
2034
|
-
[InterceptableSpec::CbEmbedsOneParent, :after_save]
|
2035
|
-
]
|
2036
|
-
end
|
2037
|
-
|
2038
|
-
it 'calls callbacks in the right order' do
|
2039
|
-
parent.save!
|
2040
|
-
expect(registry.calls).to eq expected
|
2041
|
-
end
|
1882
|
+
let(:expected) do
|
1883
|
+
[
|
1884
|
+
[InterceptableSpec::CbEmbedsOneChild, :before_validation],
|
1885
|
+
[InterceptableSpec::CbEmbedsOneChild, :after_validation],
|
1886
|
+
[InterceptableSpec::CbEmbedsOneParent, :before_validation],
|
1887
|
+
[InterceptableSpec::CbEmbedsOneChild, :before_validation],
|
1888
|
+
[InterceptableSpec::CbEmbedsOneChild, :after_validation],
|
1889
|
+
[InterceptableSpec::CbEmbedsOneParent, :after_validation],
|
1890
|
+
|
1891
|
+
[InterceptableSpec::CbEmbedsOneParent, :before_save],
|
1892
|
+
[InterceptableSpec::CbEmbedsOneParent, :around_save_open],
|
1893
|
+
[InterceptableSpec::CbEmbedsOneParent, :before_create],
|
1894
|
+
[InterceptableSpec::CbEmbedsOneParent, :around_create_open],
|
1895
|
+
|
1896
|
+
[InterceptableSpec::CbEmbedsOneChild, :before_save],
|
1897
|
+
[InterceptableSpec::CbEmbedsOneChild, :around_save_open],
|
1898
|
+
[InterceptableSpec::CbEmbedsOneChild, :before_create],
|
1899
|
+
[InterceptableSpec::CbEmbedsOneChild, :around_create_open],
|
1900
|
+
|
1901
|
+
[InterceptableSpec::CbEmbedsOneParent, :insert_into_database],
|
1902
|
+
|
1903
|
+
[InterceptableSpec::CbEmbedsOneChild, :around_create_close],
|
1904
|
+
[InterceptableSpec::CbEmbedsOneChild, :after_create],
|
1905
|
+
[InterceptableSpec::CbEmbedsOneChild, :around_save_close],
|
1906
|
+
[InterceptableSpec::CbEmbedsOneChild, :after_save],
|
1907
|
+
|
1908
|
+
[InterceptableSpec::CbEmbedsOneParent, :around_create_close],
|
1909
|
+
[InterceptableSpec::CbEmbedsOneParent, :after_create],
|
1910
|
+
[InterceptableSpec::CbEmbedsOneParent, :around_save_close],
|
1911
|
+
[InterceptableSpec::CbEmbedsOneParent, :after_save]
|
1912
|
+
]
|
2042
1913
|
end
|
2043
1914
|
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
let(:expected) do
|
2048
|
-
[
|
2049
|
-
[InterceptableSpec::CbEmbedsOneChild, :before_validation],
|
2050
|
-
[InterceptableSpec::CbEmbedsOneChild, :after_validation],
|
2051
|
-
[InterceptableSpec::CbEmbedsOneParent, :before_validation],
|
2052
|
-
[InterceptableSpec::CbEmbedsOneChild, :before_validation],
|
2053
|
-
[InterceptableSpec::CbEmbedsOneChild, :after_validation],
|
2054
|
-
[InterceptableSpec::CbEmbedsOneParent, :after_validation],
|
2055
|
-
|
2056
|
-
[InterceptableSpec::CbEmbedsOneParent, :before_save],
|
2057
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_save_open],
|
2058
|
-
[InterceptableSpec::CbEmbedsOneParent, :before_create],
|
2059
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_create_open],
|
2060
|
-
|
2061
|
-
[InterceptableSpec::CbEmbedsOneChild, :before_save],
|
2062
|
-
[InterceptableSpec::CbEmbedsOneChild, :before_create],
|
2063
|
-
|
2064
|
-
[InterceptableSpec::CbEmbedsOneParent, :insert_into_database],
|
2065
|
-
|
2066
|
-
[InterceptableSpec::CbEmbedsOneChild, :after_create],
|
2067
|
-
[InterceptableSpec::CbEmbedsOneChild, :after_save],
|
2068
|
-
|
2069
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_create_close],
|
2070
|
-
[InterceptableSpec::CbEmbedsOneParent, :after_create],
|
2071
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_save_close],
|
2072
|
-
[InterceptableSpec::CbEmbedsOneParent, :after_save]
|
2073
|
-
]
|
2074
|
-
end
|
2075
|
-
|
2076
|
-
it 'calls callbacks in the right order' do
|
2077
|
-
parent.save!
|
2078
|
-
expect(registry.calls).to eq expected
|
2079
|
-
end
|
1915
|
+
it 'calls callbacks in the right order' do
|
1916
|
+
parent.save!
|
1917
|
+
expect(registry.calls).to eq expected
|
2080
1918
|
end
|
2081
1919
|
end
|
2082
1920
|
|
2083
1921
|
context "update" do
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
[
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_save_close],
|
2114
|
-
[InterceptableSpec::CbEmbedsOneParent, :after_save]
|
2115
|
-
]
|
2116
|
-
end
|
2117
|
-
|
2118
|
-
it 'calls callbacks in the right order' do
|
2119
|
-
parent.callback_registry = nil
|
2120
|
-
parent.child.callback_registry = nil
|
2121
|
-
parent.save!
|
2122
|
-
|
2123
|
-
parent.callback_registry = registry
|
2124
|
-
parent.child.callback_registry = registry
|
2125
|
-
parent.name = "name"
|
2126
|
-
parent.child.age = 10
|
2127
|
-
|
2128
|
-
parent.save!
|
2129
|
-
expect(registry.calls).to eq expected
|
2130
|
-
end
|
1922
|
+
let(:expected) do
|
1923
|
+
[
|
1924
|
+
[InterceptableSpec::CbEmbedsOneChild, :before_validation],
|
1925
|
+
[InterceptableSpec::CbEmbedsOneChild, :after_validation],
|
1926
|
+
[InterceptableSpec::CbEmbedsOneParent, :before_validation],
|
1927
|
+
[InterceptableSpec::CbEmbedsOneChild, :before_validation],
|
1928
|
+
[InterceptableSpec::CbEmbedsOneChild, :after_validation],
|
1929
|
+
[InterceptableSpec::CbEmbedsOneParent, :after_validation],
|
1930
|
+
|
1931
|
+
[InterceptableSpec::CbEmbedsOneParent, :before_save],
|
1932
|
+
[InterceptableSpec::CbEmbedsOneParent, :around_save_open],
|
1933
|
+
[InterceptableSpec::CbEmbedsOneParent, :before_update],
|
1934
|
+
[InterceptableSpec::CbEmbedsOneParent, :around_update_open],
|
1935
|
+
|
1936
|
+
[InterceptableSpec::CbEmbedsOneChild, :before_save],
|
1937
|
+
[InterceptableSpec::CbEmbedsOneChild, :around_save_open],
|
1938
|
+
[InterceptableSpec::CbEmbedsOneChild, :before_update],
|
1939
|
+
[InterceptableSpec::CbEmbedsOneChild, :around_update_open],
|
1940
|
+
|
1941
|
+
[InterceptableSpec::CbEmbedsOneChild, :around_update_close],
|
1942
|
+
[InterceptableSpec::CbEmbedsOneChild, :after_update],
|
1943
|
+
[InterceptableSpec::CbEmbedsOneChild, :around_save_close],
|
1944
|
+
[InterceptableSpec::CbEmbedsOneChild, :after_save],
|
1945
|
+
|
1946
|
+
[InterceptableSpec::CbEmbedsOneParent, :around_update_close],
|
1947
|
+
[InterceptableSpec::CbEmbedsOneParent, :after_update],
|
1948
|
+
[InterceptableSpec::CbEmbedsOneParent, :around_save_close],
|
1949
|
+
[InterceptableSpec::CbEmbedsOneParent, :after_save]
|
1950
|
+
]
|
2131
1951
|
end
|
2132
1952
|
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
[
|
2138
|
-
[InterceptableSpec::CbEmbedsOneChild, :before_validation],
|
2139
|
-
[InterceptableSpec::CbEmbedsOneChild, :after_validation],
|
2140
|
-
[InterceptableSpec::CbEmbedsOneParent, :before_validation],
|
2141
|
-
[InterceptableSpec::CbEmbedsOneChild, :before_validation],
|
2142
|
-
[InterceptableSpec::CbEmbedsOneChild, :after_validation],
|
2143
|
-
[InterceptableSpec::CbEmbedsOneParent, :after_validation],
|
2144
|
-
|
2145
|
-
[InterceptableSpec::CbEmbedsOneParent, :before_save],
|
2146
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_save_open],
|
2147
|
-
[InterceptableSpec::CbEmbedsOneParent, :before_update],
|
2148
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_update_open],
|
2149
|
-
|
2150
|
-
[InterceptableSpec::CbEmbedsOneChild, :before_save],
|
2151
|
-
[InterceptableSpec::CbEmbedsOneChild, :before_update],
|
2152
|
-
|
2153
|
-
[InterceptableSpec::CbEmbedsOneChild, :after_update],
|
2154
|
-
[InterceptableSpec::CbEmbedsOneChild, :after_save],
|
2155
|
-
|
2156
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_update_close],
|
2157
|
-
[InterceptableSpec::CbEmbedsOneParent, :after_update],
|
2158
|
-
[InterceptableSpec::CbEmbedsOneParent, :around_save_close],
|
2159
|
-
[InterceptableSpec::CbEmbedsOneParent, :after_save]
|
2160
|
-
]
|
2161
|
-
end
|
2162
|
-
|
2163
|
-
it 'calls callbacks in the right order' do
|
2164
|
-
parent.callback_registry = nil
|
2165
|
-
parent.child.callback_registry = nil
|
2166
|
-
parent.save!
|
1953
|
+
it 'calls callbacks in the right order' do
|
1954
|
+
parent.callback_registry = nil
|
1955
|
+
parent.child.callback_registry = nil
|
1956
|
+
parent.save!
|
2167
1957
|
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
1958
|
+
parent.callback_registry = registry
|
1959
|
+
parent.child.callback_registry = registry
|
1960
|
+
parent.name = "name"
|
1961
|
+
parent.child.age = 10
|
2172
1962
|
|
2173
|
-
|
2174
|
-
|
2175
|
-
end
|
1963
|
+
parent.save!
|
1964
|
+
expect(registry.calls).to eq expected
|
2176
1965
|
end
|
2177
1966
|
end
|
2178
1967
|
end
|
@@ -2252,114 +2041,59 @@ describe Mongoid::Interceptable do
|
|
2252
2041
|
end
|
2253
2042
|
end
|
2254
2043
|
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
[
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
|
2277
|
-
|
2278
|
-
|
2279
|
-
|
2280
|
-
|
2281
|
-
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2285
|
-
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
|
2293
|
-
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
[InterceptableSpec::CbEmbedsManyParent, :around_save_close],
|
2304
|
-
[InterceptableSpec::CbEmbedsManyParent, :after_save]
|
2305
|
-
]
|
2306
|
-
end
|
2307
|
-
|
2308
|
-
it 'calls callbacks in the right order' do
|
2309
|
-
parent.save!
|
2310
|
-
expect(registry.calls).to eq expected
|
2311
|
-
end
|
2044
|
+
let(:expected) do
|
2045
|
+
[
|
2046
|
+
[InterceptableSpec::CbEmbedsManyChild, :before_validation],
|
2047
|
+
[InterceptableSpec::CbEmbedsManyChild, :after_validation],
|
2048
|
+
[InterceptableSpec::CbEmbedsManyChild, :before_validation],
|
2049
|
+
[InterceptableSpec::CbEmbedsManyChild, :after_validation],
|
2050
|
+
[InterceptableSpec::CbEmbedsManyParent, :before_validation],
|
2051
|
+
[InterceptableSpec::CbEmbedsManyChild, :before_validation],
|
2052
|
+
[InterceptableSpec::CbEmbedsManyChild, :after_validation],
|
2053
|
+
[InterceptableSpec::CbEmbedsManyChild, :before_validation],
|
2054
|
+
[InterceptableSpec::CbEmbedsManyChild, :after_validation],
|
2055
|
+
[InterceptableSpec::CbEmbedsManyParent, :after_validation],
|
2056
|
+
|
2057
|
+
[InterceptableSpec::CbEmbedsManyParent, :before_save],
|
2058
|
+
[InterceptableSpec::CbEmbedsManyParent, :around_save_open],
|
2059
|
+
[InterceptableSpec::CbEmbedsManyParent, :before_create],
|
2060
|
+
[InterceptableSpec::CbEmbedsManyParent, :around_create_open],
|
2061
|
+
|
2062
|
+
[InterceptableSpec::CbEmbedsManyChild, :before_save],
|
2063
|
+
[InterceptableSpec::CbEmbedsManyChild, :around_save_open],
|
2064
|
+
[InterceptableSpec::CbEmbedsManyChild, :before_save],
|
2065
|
+
|
2066
|
+
[InterceptableSpec::CbEmbedsManyChild, :around_save_open],
|
2067
|
+
[InterceptableSpec::CbEmbedsManyChild, :before_create],
|
2068
|
+
[InterceptableSpec::CbEmbedsManyChild, :around_create_open],
|
2069
|
+
|
2070
|
+
[InterceptableSpec::CbEmbedsManyChild, :before_create],
|
2071
|
+
[InterceptableSpec::CbEmbedsManyChild, :around_create_open],
|
2072
|
+
|
2073
|
+
[InterceptableSpec::CbEmbedsManyParent, :insert_into_database],
|
2074
|
+
|
2075
|
+
[InterceptableSpec::CbEmbedsManyChild, :around_create_close],
|
2076
|
+
[InterceptableSpec::CbEmbedsManyChild, :after_create],
|
2077
|
+
|
2078
|
+
[InterceptableSpec::CbEmbedsManyChild, :around_create_close],
|
2079
|
+
[InterceptableSpec::CbEmbedsManyChild, :after_create],
|
2080
|
+
|
2081
|
+
[InterceptableSpec::CbEmbedsManyChild, :around_save_close],
|
2082
|
+
[InterceptableSpec::CbEmbedsManyChild, :after_save],
|
2083
|
+
|
2084
|
+
[InterceptableSpec::CbEmbedsManyChild, :around_save_close],
|
2085
|
+
[InterceptableSpec::CbEmbedsManyChild, :after_save],
|
2086
|
+
|
2087
|
+
[InterceptableSpec::CbEmbedsManyParent, :around_create_close],
|
2088
|
+
[InterceptableSpec::CbEmbedsManyParent, :after_create],
|
2089
|
+
[InterceptableSpec::CbEmbedsManyParent, :around_save_close],
|
2090
|
+
[InterceptableSpec::CbEmbedsManyParent, :after_save]
|
2091
|
+
]
|
2312
2092
|
end
|
2313
2093
|
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
let(:expected) do
|
2318
|
-
[
|
2319
|
-
[InterceptableSpec::CbEmbedsManyChild, :before_validation],
|
2320
|
-
[InterceptableSpec::CbEmbedsManyChild, :after_validation],
|
2321
|
-
[InterceptableSpec::CbEmbedsManyChild, :before_validation],
|
2322
|
-
[InterceptableSpec::CbEmbedsManyChild, :after_validation],
|
2323
|
-
[InterceptableSpec::CbEmbedsManyParent, :before_validation],
|
2324
|
-
[InterceptableSpec::CbEmbedsManyChild, :before_validation],
|
2325
|
-
[InterceptableSpec::CbEmbedsManyChild, :after_validation],
|
2326
|
-
[InterceptableSpec::CbEmbedsManyChild, :before_validation],
|
2327
|
-
[InterceptableSpec::CbEmbedsManyChild, :after_validation],
|
2328
|
-
[InterceptableSpec::CbEmbedsManyParent, :after_validation],
|
2329
|
-
|
2330
|
-
[InterceptableSpec::CbEmbedsManyParent, :before_save],
|
2331
|
-
[InterceptableSpec::CbEmbedsManyParent, :around_save_open],
|
2332
|
-
[InterceptableSpec::CbEmbedsManyParent, :before_create],
|
2333
|
-
[InterceptableSpec::CbEmbedsManyParent, :around_create_open],
|
2334
|
-
|
2335
|
-
[InterceptableSpec::CbEmbedsManyChild, :before_save],
|
2336
|
-
[InterceptableSpec::CbEmbedsManyChild, :before_save],
|
2337
|
-
|
2338
|
-
[InterceptableSpec::CbEmbedsManyChild, :before_create],
|
2339
|
-
|
2340
|
-
[InterceptableSpec::CbEmbedsManyChild, :before_create],
|
2341
|
-
|
2342
|
-
[InterceptableSpec::CbEmbedsManyParent, :insert_into_database],
|
2343
|
-
|
2344
|
-
[InterceptableSpec::CbEmbedsManyChild, :after_create],
|
2345
|
-
|
2346
|
-
[InterceptableSpec::CbEmbedsManyChild, :after_create],
|
2347
|
-
|
2348
|
-
[InterceptableSpec::CbEmbedsManyChild, :after_save],
|
2349
|
-
|
2350
|
-
[InterceptableSpec::CbEmbedsManyChild, :after_save],
|
2351
|
-
|
2352
|
-
[InterceptableSpec::CbEmbedsManyParent, :around_create_close],
|
2353
|
-
[InterceptableSpec::CbEmbedsManyParent, :after_create],
|
2354
|
-
[InterceptableSpec::CbEmbedsManyParent, :around_save_close],
|
2355
|
-
[InterceptableSpec::CbEmbedsManyParent, :after_save]
|
2356
|
-
]
|
2357
|
-
end
|
2358
|
-
|
2359
|
-
it 'calls callbacks in the right order' do
|
2360
|
-
parent.save!
|
2361
|
-
expect(registry.calls).to eq expected
|
2362
|
-
end
|
2094
|
+
it 'calls callbacks in the right order' do
|
2095
|
+
parent.save!
|
2096
|
+
expect(registry.calls).to eq expected
|
2363
2097
|
end
|
2364
2098
|
end
|
2365
2099
|
end
|
@@ -2648,27 +2382,4 @@ describe Mongoid::Interceptable do
|
|
2648
2382
|
end.to_not raise_error(ActiveModel::MissingAttributeError)
|
2649
2383
|
end
|
2650
2384
|
end
|
2651
|
-
|
2652
|
-
context "when around callbacks for embedded are disabled" do
|
2653
|
-
config_override :around_callbacks_for_embeds, false
|
2654
|
-
|
2655
|
-
context "when around callback is defined" do
|
2656
|
-
let(:registry) { InterceptableSpec::CallbackRegistry.new }
|
2657
|
-
|
2658
|
-
let(:parent) do
|
2659
|
-
InterceptableSpec::CbEmbedsOneParent.new(registry).tap do |parent|
|
2660
|
-
parent.child = InterceptableSpec::CbEmbedsOneChild.new(registry)
|
2661
|
-
end
|
2662
|
-
end
|
2663
|
-
|
2664
|
-
before do
|
2665
|
-
expect(Mongoid.logger).to receive(:warn).with(/Around callbacks are disabled for embedded documents/).twice.and_call_original
|
2666
|
-
expect(Mongoid.logger).to receive(:warn).with(/To enable around callbacks for embedded documents/).twice.and_call_original
|
2667
|
-
end
|
2668
|
-
|
2669
|
-
it "logs a warning" do
|
2670
|
-
parent.save!
|
2671
|
-
end
|
2672
|
-
end
|
2673
|
-
end
|
2674
2385
|
end
|