mongoid 8.0.5 → 8.0.7

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/mongoid/association/macros.rb +6 -0
  4. data/lib/mongoid/attributes/processing.rb +29 -5
  5. data/lib/mongoid/config/options.rb +3 -0
  6. data/lib/mongoid/config.rb +30 -0
  7. data/lib/mongoid/contextual/mongo.rb +24 -1
  8. data/lib/mongoid/criteria/queryable/selector.rb +1 -1
  9. data/lib/mongoid/criteria/queryable/storable.rb +1 -1
  10. data/lib/mongoid/deprecable.rb +3 -2
  11. data/lib/mongoid/deprecation.rb +3 -3
  12. data/lib/mongoid/extensions/hash.rb +24 -2
  13. data/lib/mongoid/fields.rb +45 -18
  14. data/lib/mongoid/interceptable.rb +122 -13
  15. data/lib/mongoid/version.rb +1 -1
  16. data/spec/integration/callbacks_spec.rb +20 -0
  17. data/spec/mongoid/attributes_spec.rb +27 -0
  18. data/spec/mongoid/config_spec.rb +11 -2
  19. data/spec/mongoid/contextual/mongo_spec.rb +89 -14
  20. data/spec/mongoid/copyable_spec.rb +1 -1
  21. data/spec/mongoid/criteria/queryable/selector_spec.rb +75 -2
  22. data/spec/mongoid/criteria/queryable/storable_spec.rb +72 -0
  23. data/spec/mongoid/extensions/hash_spec.rb +3 -3
  24. data/spec/mongoid/fields_spec.rb +43 -0
  25. data/spec/mongoid/interceptable_spec.rb +362 -161
  26. data/spec/shared/lib/mrss/docker_runner.rb +7 -0
  27. data/spec/shared/lib/mrss/event_subscriber.rb +15 -5
  28. data/spec/shared/lib/mrss/lite_constraints.rb +10 -2
  29. data/spec/shared/lib/mrss/server_version_registry.rb +16 -23
  30. data/spec/shared/lib/mrss/utils.rb +28 -6
  31. data/spec/shared/share/Dockerfile.erb +36 -40
  32. data/spec/shared/shlib/server.sh +32 -8
  33. data/spec/shared/shlib/set_env.sh +4 -4
  34. data/spec/support/models/person.rb +1 -0
  35. data/spec/support/models/purse.rb +9 -0
  36. data.tar.gz.sig +0 -0
  37. metadata +10 -8
  38. metadata.gz.sig +0 -0
@@ -578,14 +578,6 @@ describe Mongoid::Interceptable do
578
578
  band.notes.push(note)
579
579
  record.notes.push(note)
580
580
  end
581
-
582
- context "when saving the root" do
583
-
584
- it "only executes the callbacks once for each embed" do
585
- expect(note).to receive(:update_saved).twice
586
- band.save!
587
- end
588
- end
589
581
  end
590
582
  end
591
583
 
@@ -1771,40 +1763,80 @@ describe Mongoid::Interceptable do
1771
1763
  end
1772
1764
  end
1773
1765
 
1774
- let(:expected) do
1775
- [
1776
- [InterceptableSpec::CbCascadedChild, :before_validation],
1777
- [InterceptableSpec::CbCascadedChild, :after_validation],
1778
- [InterceptableSpec::CbParent, :before_validation],
1779
- [InterceptableSpec::CbCascadedChild, :before_validation],
1780
- [InterceptableSpec::CbCascadedChild, :after_validation],
1766
+ context 'with around callbacks' do
1767
+ config_override :around_callbacks_for_embeds, true
1781
1768
 
1782
- [InterceptableSpec::CbParent, :after_validation],
1783
- [InterceptableSpec::CbParent, :before_save],
1784
- [InterceptableSpec::CbParent, :around_save_open],
1785
- [InterceptableSpec::CbParent, :before_create],
1786
- [InterceptableSpec::CbParent, :around_create_open],
1769
+ let(:expected) do
1770
+ [
1771
+ [InterceptableSpec::CbCascadedChild, :before_validation],
1772
+ [InterceptableSpec::CbCascadedChild, :after_validation],
1773
+ [InterceptableSpec::CbParent, :before_validation],
1774
+ [InterceptableSpec::CbCascadedChild, :before_validation],
1775
+ [InterceptableSpec::CbCascadedChild, :after_validation],
1776
+
1777
+ [InterceptableSpec::CbParent, :after_validation],
1778
+ [InterceptableSpec::CbParent, :before_save],
1779
+ [InterceptableSpec::CbParent, :around_save_open],
1780
+ [InterceptableSpec::CbParent, :before_create],
1781
+ [InterceptableSpec::CbParent, :around_create_open],
1782
+
1783
+ [InterceptableSpec::CbCascadedChild, :before_save],
1784
+ [InterceptableSpec::CbCascadedChild, :around_save_open],
1785
+ [InterceptableSpec::CbCascadedChild, :before_create],
1786
+ [InterceptableSpec::CbCascadedChild, :around_create_open],
1787
+
1788
+ [InterceptableSpec::CbCascadedChild, :around_create_close],
1789
+ [InterceptableSpec::CbCascadedChild, :after_create],
1790
+ [InterceptableSpec::CbCascadedChild, :around_save_close],
1791
+ [InterceptableSpec::CbCascadedChild, :after_save],
1792
+
1793
+ [InterceptableSpec::CbParent, :around_create_close],
1794
+ [InterceptableSpec::CbParent, :after_create],
1795
+ [InterceptableSpec::CbParent, :around_save_close],
1796
+ [InterceptableSpec::CbParent, :after_save]
1797
+ ]
1798
+ end
1787
1799
 
1788
- [InterceptableSpec::CbCascadedChild, :before_save],
1789
- [InterceptableSpec::CbCascadedChild, :around_save_open],
1790
- [InterceptableSpec::CbCascadedChild, :before_create],
1791
- [InterceptableSpec::CbCascadedChild, :around_create_open],
1800
+ it 'calls callbacks in the right order' do
1801
+ parent.save!
1802
+ expect(registry.calls).to eq expected
1803
+ end
1804
+ end
1792
1805
 
1793
- [InterceptableSpec::CbCascadedChild, :around_create_close],
1794
- [InterceptableSpec::CbCascadedChild, :after_create],
1795
- [InterceptableSpec::CbCascadedChild, :around_save_close],
1796
- [InterceptableSpec::CbCascadedChild, :after_save],
1806
+ context 'without around callbacks' do
1807
+ config_override :around_callbacks_for_embeds, false
1797
1808
 
1798
- [InterceptableSpec::CbParent, :around_create_close],
1799
- [InterceptableSpec::CbParent, :after_create],
1800
- [InterceptableSpec::CbParent, :around_save_close],
1801
- [InterceptableSpec::CbParent, :after_save]
1802
- ]
1803
- end
1809
+ let(:expected) do
1810
+ [
1811
+ [InterceptableSpec::CbCascadedChild, :before_validation],
1812
+ [InterceptableSpec::CbCascadedChild, :after_validation],
1813
+ [InterceptableSpec::CbParent, :before_validation],
1814
+ [InterceptableSpec::CbCascadedChild, :before_validation],
1815
+ [InterceptableSpec::CbCascadedChild, :after_validation],
1816
+
1817
+ [InterceptableSpec::CbParent, :after_validation],
1818
+ [InterceptableSpec::CbParent, :before_save],
1819
+ [InterceptableSpec::CbParent, :around_save_open],
1820
+ [InterceptableSpec::CbParent, :before_create],
1821
+ [InterceptableSpec::CbParent, :around_create_open],
1822
+
1823
+ [InterceptableSpec::CbCascadedChild, :before_save],
1824
+ [InterceptableSpec::CbCascadedChild, :before_create],
1825
+
1826
+ [InterceptableSpec::CbCascadedChild, :after_create],
1827
+ [InterceptableSpec::CbCascadedChild, :after_save],
1828
+
1829
+ [InterceptableSpec::CbParent, :around_create_close],
1830
+ [InterceptableSpec::CbParent, :after_create],
1831
+ [InterceptableSpec::CbParent, :around_save_close],
1832
+ [InterceptableSpec::CbParent, :after_save]
1833
+ ]
1834
+ end
1804
1835
 
1805
- it 'calls callbacks in the right order' do
1806
- parent.save!
1807
- expect(registry.calls).to eq expected
1836
+ it 'calls callbacks in the right order' do
1837
+ parent.save!
1838
+ expect(registry.calls).to eq expected
1839
+ end
1808
1840
  end
1809
1841
  end
1810
1842
 
@@ -1867,89 +1899,180 @@ describe Mongoid::Interceptable do
1867
1899
  end
1868
1900
 
1869
1901
  context "create" do
1870
- let(:expected) do
1871
- [
1872
- [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1873
- [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1874
- [InterceptableSpec::CbEmbedsOneParent, :before_validation],
1875
- [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1876
- [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1877
- [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1878
-
1879
- [InterceptableSpec::CbEmbedsOneParent, :before_save],
1880
- [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
1881
- [InterceptableSpec::CbEmbedsOneParent, :before_create],
1882
- [InterceptableSpec::CbEmbedsOneParent, :around_create_open],
1883
-
1884
- [InterceptableSpec::CbEmbedsOneChild, :before_save],
1885
- [InterceptableSpec::CbEmbedsOneChild, :around_save_open],
1886
- [InterceptableSpec::CbEmbedsOneChild, :before_create],
1887
- [InterceptableSpec::CbEmbedsOneChild, :around_create_open],
1888
-
1889
- [InterceptableSpec::CbEmbedsOneParent, :insert_into_database],
1890
-
1891
- [InterceptableSpec::CbEmbedsOneChild, :around_create_close],
1892
- [InterceptableSpec::CbEmbedsOneChild, :after_create],
1893
- [InterceptableSpec::CbEmbedsOneChild, :around_save_close],
1894
- [InterceptableSpec::CbEmbedsOneChild, :after_save],
1895
-
1896
- [InterceptableSpec::CbEmbedsOneParent, :around_create_close],
1897
- [InterceptableSpec::CbEmbedsOneParent, :after_create],
1898
- [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
1899
- [InterceptableSpec::CbEmbedsOneParent, :after_save]
1900
- ]
1902
+ context "with around callbacks" do
1903
+ config_override :around_callbacks_for_embeds, true
1904
+
1905
+ let(:expected) do
1906
+ [
1907
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1908
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1909
+ [InterceptableSpec::CbEmbedsOneParent, :before_validation],
1910
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1911
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1912
+ [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1913
+
1914
+ [InterceptableSpec::CbEmbedsOneParent, :before_save],
1915
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
1916
+ [InterceptableSpec::CbEmbedsOneParent, :before_create],
1917
+ [InterceptableSpec::CbEmbedsOneParent, :around_create_open],
1918
+
1919
+ [InterceptableSpec::CbEmbedsOneChild, :before_save],
1920
+ [InterceptableSpec::CbEmbedsOneChild, :around_save_open],
1921
+ [InterceptableSpec::CbEmbedsOneChild, :before_create],
1922
+ [InterceptableSpec::CbEmbedsOneChild, :around_create_open],
1923
+
1924
+ [InterceptableSpec::CbEmbedsOneParent, :insert_into_database],
1925
+
1926
+ [InterceptableSpec::CbEmbedsOneChild, :around_create_close],
1927
+ [InterceptableSpec::CbEmbedsOneChild, :after_create],
1928
+ [InterceptableSpec::CbEmbedsOneChild, :around_save_close],
1929
+ [InterceptableSpec::CbEmbedsOneChild, :after_save],
1930
+
1931
+ [InterceptableSpec::CbEmbedsOneParent, :around_create_close],
1932
+ [InterceptableSpec::CbEmbedsOneParent, :after_create],
1933
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
1934
+ [InterceptableSpec::CbEmbedsOneParent, :after_save]
1935
+ ]
1936
+ end
1937
+
1938
+ it 'calls callbacks in the right order' do
1939
+ parent.save!
1940
+ expect(registry.calls).to eq expected
1941
+ end
1901
1942
  end
1902
1943
 
1903
- it 'calls callbacks in the right order' do
1904
- parent.save!
1905
- expect(registry.calls).to eq expected
1944
+ context "without around callbacks" do
1945
+ config_override :around_callbacks_for_embeds, false
1946
+
1947
+ let(:expected) do
1948
+ [
1949
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1950
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1951
+ [InterceptableSpec::CbEmbedsOneParent, :before_validation],
1952
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1953
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1954
+ [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1955
+
1956
+ [InterceptableSpec::CbEmbedsOneParent, :before_save],
1957
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
1958
+ [InterceptableSpec::CbEmbedsOneParent, :before_create],
1959
+ [InterceptableSpec::CbEmbedsOneParent, :around_create_open],
1960
+
1961
+ [InterceptableSpec::CbEmbedsOneChild, :before_save],
1962
+ [InterceptableSpec::CbEmbedsOneChild, :before_create],
1963
+
1964
+ [InterceptableSpec::CbEmbedsOneParent, :insert_into_database],
1965
+
1966
+ [InterceptableSpec::CbEmbedsOneChild, :after_create],
1967
+ [InterceptableSpec::CbEmbedsOneChild, :after_save],
1968
+
1969
+ [InterceptableSpec::CbEmbedsOneParent, :around_create_close],
1970
+ [InterceptableSpec::CbEmbedsOneParent, :after_create],
1971
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
1972
+ [InterceptableSpec::CbEmbedsOneParent, :after_save]
1973
+ ]
1974
+ end
1975
+
1976
+ it 'calls callbacks in the right order' do
1977
+ parent.save!
1978
+ expect(registry.calls).to eq expected
1979
+ end
1906
1980
  end
1907
1981
  end
1908
1982
 
1909
1983
  context "update" do
1910
- let(:expected) do
1911
- [
1912
- [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1913
- [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1914
- [InterceptableSpec::CbEmbedsOneParent, :before_validation],
1915
- [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1916
- [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1917
- [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1918
-
1919
- [InterceptableSpec::CbEmbedsOneParent, :before_save],
1920
- [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
1921
- [InterceptableSpec::CbEmbedsOneParent, :before_update],
1922
- [InterceptableSpec::CbEmbedsOneParent, :around_update_open],
1923
-
1924
- [InterceptableSpec::CbEmbedsOneChild, :before_save],
1925
- [InterceptableSpec::CbEmbedsOneChild, :around_save_open],
1926
- [InterceptableSpec::CbEmbedsOneChild, :before_update],
1927
- [InterceptableSpec::CbEmbedsOneChild, :around_update_open],
1928
-
1929
- [InterceptableSpec::CbEmbedsOneChild, :around_update_close],
1930
- [InterceptableSpec::CbEmbedsOneChild, :after_update],
1931
- [InterceptableSpec::CbEmbedsOneChild, :around_save_close],
1932
- [InterceptableSpec::CbEmbedsOneChild, :after_save],
1933
-
1934
- [InterceptableSpec::CbEmbedsOneParent, :around_update_close],
1935
- [InterceptableSpec::CbEmbedsOneParent, :after_update],
1936
- [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
1937
- [InterceptableSpec::CbEmbedsOneParent, :after_save]
1938
- ]
1984
+ context "with around callbacks" do
1985
+ config_override :around_callbacks_for_embeds, true
1986
+
1987
+ let(:expected) do
1988
+ [
1989
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1990
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1991
+ [InterceptableSpec::CbEmbedsOneParent, :before_validation],
1992
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1993
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1994
+ [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1995
+
1996
+ [InterceptableSpec::CbEmbedsOneParent, :before_save],
1997
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
1998
+ [InterceptableSpec::CbEmbedsOneParent, :before_update],
1999
+ [InterceptableSpec::CbEmbedsOneParent, :around_update_open],
2000
+
2001
+ [InterceptableSpec::CbEmbedsOneChild, :before_save],
2002
+ [InterceptableSpec::CbEmbedsOneChild, :around_save_open],
2003
+ [InterceptableSpec::CbEmbedsOneChild, :before_update],
2004
+ [InterceptableSpec::CbEmbedsOneChild, :around_update_open],
2005
+
2006
+ [InterceptableSpec::CbEmbedsOneChild, :around_update_close],
2007
+ [InterceptableSpec::CbEmbedsOneChild, :after_update],
2008
+ [InterceptableSpec::CbEmbedsOneChild, :around_save_close],
2009
+ [InterceptableSpec::CbEmbedsOneChild, :after_save],
2010
+
2011
+ [InterceptableSpec::CbEmbedsOneParent, :around_update_close],
2012
+ [InterceptableSpec::CbEmbedsOneParent, :after_update],
2013
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
2014
+ [InterceptableSpec::CbEmbedsOneParent, :after_save]
2015
+ ]
2016
+ end
2017
+
2018
+ it 'calls callbacks in the right order' do
2019
+ parent.callback_registry = nil
2020
+ parent.child.callback_registry = nil
2021
+ parent.save!
2022
+
2023
+ parent.callback_registry = registry
2024
+ parent.child.callback_registry = registry
2025
+ parent.name = "name"
2026
+ parent.child.age = 10
2027
+
2028
+ parent.save!
2029
+ expect(registry.calls).to eq expected
2030
+ end
1939
2031
  end
1940
2032
 
1941
- it 'calls callbacks in the right order' do
1942
- parent.callback_registry = nil
1943
- parent.child.callback_registry = nil
1944
- parent.save!
2033
+ context "without around callbacks" do
2034
+ config_override :around_callbacks_for_embeds, false
1945
2035
 
1946
- parent.callback_registry = registry
1947
- parent.child.callback_registry = registry
1948
- parent.name = "name"
1949
- parent.child.age = 10
2036
+ let(:expected) do
2037
+ [
2038
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
2039
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
2040
+ [InterceptableSpec::CbEmbedsOneParent, :before_validation],
2041
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
2042
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
2043
+ [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1950
2044
 
1951
- parent.save!
1952
- expect(registry.calls).to eq expected
2045
+ [InterceptableSpec::CbEmbedsOneParent, :before_save],
2046
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
2047
+ [InterceptableSpec::CbEmbedsOneParent, :before_update],
2048
+ [InterceptableSpec::CbEmbedsOneParent, :around_update_open],
2049
+
2050
+ [InterceptableSpec::CbEmbedsOneChild, :before_save],
2051
+ [InterceptableSpec::CbEmbedsOneChild, :before_update],
2052
+
2053
+ [InterceptableSpec::CbEmbedsOneChild, :after_update],
2054
+ [InterceptableSpec::CbEmbedsOneChild, :after_save],
2055
+
2056
+ [InterceptableSpec::CbEmbedsOneParent, :around_update_close],
2057
+ [InterceptableSpec::CbEmbedsOneParent, :after_update],
2058
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
2059
+ [InterceptableSpec::CbEmbedsOneParent, :after_save]
2060
+ ]
2061
+ end
2062
+
2063
+ it 'calls callbacks in the right order' do
2064
+ parent.callback_registry = nil
2065
+ parent.child.callback_registry = nil
2066
+ parent.save!
2067
+
2068
+ parent.callback_registry = registry
2069
+ parent.child.callback_registry = registry
2070
+ parent.name = "name"
2071
+ parent.child.age = 10
2072
+
2073
+ parent.save!
2074
+ expect(registry.calls).to eq expected
2075
+ end
1953
2076
  end
1954
2077
  end
1955
2078
  end
@@ -2029,59 +2152,114 @@ describe Mongoid::Interceptable do
2029
2152
  end
2030
2153
  end
2031
2154
 
2032
- let(:expected) do
2033
- [
2034
- [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2035
- [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2036
- [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2037
- [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2038
- [InterceptableSpec::CbEmbedsManyParent, :before_validation],
2039
- [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2040
- [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2041
- [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2042
- [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2043
- [InterceptableSpec::CbEmbedsManyParent, :after_validation],
2044
-
2045
- [InterceptableSpec::CbEmbedsManyParent, :before_save],
2046
- [InterceptableSpec::CbEmbedsManyParent, :around_save_open],
2047
- [InterceptableSpec::CbEmbedsManyParent, :before_create],
2048
- [InterceptableSpec::CbEmbedsManyParent, :around_create_open],
2049
-
2050
- [InterceptableSpec::CbEmbedsManyChild, :before_save],
2051
- [InterceptableSpec::CbEmbedsManyChild, :around_save_open],
2052
- [InterceptableSpec::CbEmbedsManyChild, :before_save],
2053
-
2054
- [InterceptableSpec::CbEmbedsManyChild, :around_save_open],
2055
- [InterceptableSpec::CbEmbedsManyChild, :before_create],
2056
- [InterceptableSpec::CbEmbedsManyChild, :around_create_open],
2057
-
2058
- [InterceptableSpec::CbEmbedsManyChild, :before_create],
2059
- [InterceptableSpec::CbEmbedsManyChild, :around_create_open],
2060
-
2061
- [InterceptableSpec::CbEmbedsManyParent, :insert_into_database],
2062
-
2063
- [InterceptableSpec::CbEmbedsManyChild, :around_create_close],
2064
- [InterceptableSpec::CbEmbedsManyChild, :after_create],
2065
-
2066
- [InterceptableSpec::CbEmbedsManyChild, :around_create_close],
2067
- [InterceptableSpec::CbEmbedsManyChild, :after_create],
2068
-
2069
- [InterceptableSpec::CbEmbedsManyChild, :around_save_close],
2070
- [InterceptableSpec::CbEmbedsManyChild, :after_save],
2071
-
2072
- [InterceptableSpec::CbEmbedsManyChild, :around_save_close],
2073
- [InterceptableSpec::CbEmbedsManyChild, :after_save],
2074
-
2075
- [InterceptableSpec::CbEmbedsManyParent, :around_create_close],
2076
- [InterceptableSpec::CbEmbedsManyParent, :after_create],
2077
- [InterceptableSpec::CbEmbedsManyParent, :around_save_close],
2078
- [InterceptableSpec::CbEmbedsManyParent, :after_save]
2079
- ]
2155
+ context "with around callbacks" do
2156
+ config_override :around_callbacks_for_embeds, true
2157
+
2158
+ let(:expected) do
2159
+ [
2160
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2161
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2162
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2163
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2164
+ [InterceptableSpec::CbEmbedsManyParent, :before_validation],
2165
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2166
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2167
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2168
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2169
+ [InterceptableSpec::CbEmbedsManyParent, :after_validation],
2170
+
2171
+ [InterceptableSpec::CbEmbedsManyParent, :before_save],
2172
+ [InterceptableSpec::CbEmbedsManyParent, :around_save_open],
2173
+ [InterceptableSpec::CbEmbedsManyParent, :before_create],
2174
+ [InterceptableSpec::CbEmbedsManyParent, :around_create_open],
2175
+
2176
+ [InterceptableSpec::CbEmbedsManyChild, :before_save],
2177
+ [InterceptableSpec::CbEmbedsManyChild, :around_save_open],
2178
+ [InterceptableSpec::CbEmbedsManyChild, :before_save],
2179
+
2180
+ [InterceptableSpec::CbEmbedsManyChild, :around_save_open],
2181
+ [InterceptableSpec::CbEmbedsManyChild, :before_create],
2182
+ [InterceptableSpec::CbEmbedsManyChild, :around_create_open],
2183
+
2184
+ [InterceptableSpec::CbEmbedsManyChild, :before_create],
2185
+ [InterceptableSpec::CbEmbedsManyChild, :around_create_open],
2186
+
2187
+ [InterceptableSpec::CbEmbedsManyParent, :insert_into_database],
2188
+
2189
+ [InterceptableSpec::CbEmbedsManyChild, :around_create_close],
2190
+ [InterceptableSpec::CbEmbedsManyChild, :after_create],
2191
+
2192
+ [InterceptableSpec::CbEmbedsManyChild, :around_create_close],
2193
+ [InterceptableSpec::CbEmbedsManyChild, :after_create],
2194
+
2195
+ [InterceptableSpec::CbEmbedsManyChild, :around_save_close],
2196
+ [InterceptableSpec::CbEmbedsManyChild, :after_save],
2197
+
2198
+ [InterceptableSpec::CbEmbedsManyChild, :around_save_close],
2199
+ [InterceptableSpec::CbEmbedsManyChild, :after_save],
2200
+
2201
+ [InterceptableSpec::CbEmbedsManyParent, :around_create_close],
2202
+ [InterceptableSpec::CbEmbedsManyParent, :after_create],
2203
+ [InterceptableSpec::CbEmbedsManyParent, :around_save_close],
2204
+ [InterceptableSpec::CbEmbedsManyParent, :after_save]
2205
+ ]
2206
+ end
2207
+
2208
+ it 'calls callbacks in the right order' do
2209
+ parent.save!
2210
+ expect(registry.calls).to eq expected
2211
+ end
2080
2212
  end
2081
2213
 
2082
- it 'calls callbacks in the right order' do
2083
- parent.save!
2084
- expect(registry.calls).to eq expected
2214
+ context "without around callbacks" do
2215
+ config_override :around_callbacks_for_embeds, false
2216
+
2217
+ let(:expected) do
2218
+ [
2219
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2220
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2221
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2222
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2223
+ [InterceptableSpec::CbEmbedsManyParent, :before_validation],
2224
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2225
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2226
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2227
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2228
+ [InterceptableSpec::CbEmbedsManyParent, :after_validation],
2229
+
2230
+ [InterceptableSpec::CbEmbedsManyParent, :before_save],
2231
+ [InterceptableSpec::CbEmbedsManyParent, :around_save_open],
2232
+ [InterceptableSpec::CbEmbedsManyParent, :before_create],
2233
+ [InterceptableSpec::CbEmbedsManyParent, :around_create_open],
2234
+
2235
+ [InterceptableSpec::CbEmbedsManyChild, :before_save],
2236
+ [InterceptableSpec::CbEmbedsManyChild, :before_save],
2237
+
2238
+ [InterceptableSpec::CbEmbedsManyChild, :before_create],
2239
+
2240
+ [InterceptableSpec::CbEmbedsManyChild, :before_create],
2241
+
2242
+ [InterceptableSpec::CbEmbedsManyParent, :insert_into_database],
2243
+
2244
+ [InterceptableSpec::CbEmbedsManyChild, :after_create],
2245
+
2246
+ [InterceptableSpec::CbEmbedsManyChild, :after_create],
2247
+
2248
+ [InterceptableSpec::CbEmbedsManyChild, :after_save],
2249
+
2250
+ [InterceptableSpec::CbEmbedsManyChild, :after_save],
2251
+
2252
+ [InterceptableSpec::CbEmbedsManyParent, :around_create_close],
2253
+ [InterceptableSpec::CbEmbedsManyParent, :after_create],
2254
+ [InterceptableSpec::CbEmbedsManyParent, :around_save_close],
2255
+ [InterceptableSpec::CbEmbedsManyParent, :after_save]
2256
+ ]
2257
+ end
2258
+
2259
+ it 'calls callbacks in the right order' do
2260
+ parent.save!
2261
+ expect(registry.calls).to eq expected
2262
+ end
2085
2263
  end
2086
2264
  end
2087
2265
  end
@@ -2370,4 +2548,27 @@ describe Mongoid::Interceptable do
2370
2548
  end.to_not raise_error(ActiveModel::MissingAttributeError)
2371
2549
  end
2372
2550
  end
2551
+
2552
+ context "when around callbacks for embedded are disabled" do
2553
+ config_override :around_callbacks_for_embeds, false
2554
+
2555
+ context "when around callback is defined" do
2556
+ let(:registry) { InterceptableSpec::CallbackRegistry.new }
2557
+
2558
+ let(:parent) do
2559
+ InterceptableSpec::CbEmbedsOneParent.new(registry).tap do |parent|
2560
+ parent.child = InterceptableSpec::CbEmbedsOneChild.new(registry)
2561
+ end
2562
+ end
2563
+
2564
+ before do
2565
+ expect(Mongoid.logger).to receive(:warn).with(/Around callbacks are disabled for embedded documents/).twice.and_call_original
2566
+ expect(Mongoid.logger).to receive(:warn).with(/To enable around callbacks for embedded documents/).twice.and_call_original
2567
+ end
2568
+
2569
+ it "logs a warning" do
2570
+ parent.save!
2571
+ end
2572
+ end
2573
+ end
2373
2574
  end
@@ -195,12 +195,15 @@ module Mrss
195
195
  'debian81' => 'debian:jessie',
196
196
  'debian92' => 'debian:stretch',
197
197
  'debian10' => 'debian:buster',
198
+ 'debian11' => 'debian:bullseye',
198
199
  'ubuntu1404' => 'ubuntu:trusty',
199
200
  'ubuntu1604' => 'ubuntu:xenial',
200
201
  'ubuntu1804' => 'ubuntu:bionic',
201
202
  'ubuntu2004' => 'ubuntu:focal',
203
+ 'ubuntu2204' => 'ubuntu:jammy',
202
204
  'rhel62' => 'centos:6',
203
205
  'rhel70' => 'centos:7',
206
+ 'rhel80' => 'rockylinux:8',
204
207
  }.freeze
205
208
 
206
209
  def base_image
@@ -231,6 +234,10 @@ module Mrss
231
234
  distro =~ /debian|ubuntu/
232
235
  end
233
236
 
237
+ def ubuntu?
238
+ distro=~ /ubuntu/
239
+ end
240
+
234
241
  def preload?
235
242
  !!@options[:preload]
236
243
  end
@@ -84,22 +84,32 @@ module Mrss
84
84
 
85
85
  # Locates command stated events for the specified command name,
86
86
  # asserts that there is exactly one such event, and returns it.
87
- def single_command_started_event(command_name, include_auth: false)
87
+ def single_command_started_event(command_name, include_auth: false, database_name: nil)
88
88
  events = if include_auth
89
89
  started_events
90
90
  else
91
91
  non_auth_command_started_events
92
92
  end
93
- events.select! do |event|
94
- event.command[command_name]
93
+ get_one_event(events, command_name, 'started', database_name: database_name)
94
+ end
95
+
96
+ # Locates command succeeded events for the specified command name,
97
+ # asserts that there is exactly one such event, and returns it.
98
+ def single_command_succeeded_event(command_name, database_name: nil)
99
+ get_one_event(succeeded_events, command_name, 'succeeded', database_name: database_name)
100
+ end
101
+
102
+ def get_one_event(events, command_name, kind, database_name: nil)
103
+ events = events.select do |event|
104
+ event.command_name == command_name and
105
+ database_name.nil? || database_name == event.database_name
95
106
  end
96
107
  if events.length != 1
97
- raise "Expected a single #{command_name} event but we have #{events.length}"
108
+ raise "Expected a single '#{command_name}' #{kind} event#{database_name ? " for '#{database_name}'" : ''} but we have #{events.length}"
98
109
  end
99
110
  events.first
100
111
  end
101
112
 
102
-
103
113
  # Get the first succeeded event published for the name, and then delete it.
104
114
  #
105
115
  # @param [ String ] name The event name.