mongoid 8.1.2 → 8.1.3

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.
@@ -582,6 +582,7 @@ describe Mongoid::Interceptable do
582
582
  context "when saving the root" do
583
583
  context 'with prevent_multiple_calls_of_embedded_callbacks enabled' do
584
584
  config_override :prevent_multiple_calls_of_embedded_callbacks, true
585
+ config_override :around_callbacks_for_embeds, true
585
586
 
586
587
  it "executes the callbacks only once for each document" do
587
588
  expect(note).to receive(:update_saved).once
@@ -591,6 +592,7 @@ describe Mongoid::Interceptable do
591
592
 
592
593
  context 'with prevent_multiple_calls_of_embedded_callbacks disabled' do
593
594
  config_override :prevent_multiple_calls_of_embedded_callbacks, false
595
+ config_override :around_callbacks_for_embeds, true
594
596
 
595
597
  it "executes the callbacks once for each ember" do
596
598
  expect(note).to receive(:update_saved).twice
@@ -1783,40 +1785,80 @@ describe Mongoid::Interceptable do
1783
1785
  end
1784
1786
  end
1785
1787
 
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],
1788
+ context 'with around callbacks' do
1789
+ config_override :around_callbacks_for_embeds, true
1793
1790
 
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],
1791
+ let(:expected) do
1792
+ [
1793
+ [InterceptableSpec::CbCascadedChild, :before_validation],
1794
+ [InterceptableSpec::CbCascadedChild, :after_validation],
1795
+ [InterceptableSpec::CbParent, :before_validation],
1796
+ [InterceptableSpec::CbCascadedChild, :before_validation],
1797
+ [InterceptableSpec::CbCascadedChild, :after_validation],
1798
+
1799
+ [InterceptableSpec::CbParent, :after_validation],
1800
+ [InterceptableSpec::CbParent, :before_save],
1801
+ [InterceptableSpec::CbParent, :around_save_open],
1802
+ [InterceptableSpec::CbParent, :before_create],
1803
+ [InterceptableSpec::CbParent, :around_create_open],
1804
+
1805
+ [InterceptableSpec::CbCascadedChild, :before_save],
1806
+ [InterceptableSpec::CbCascadedChild, :around_save_open],
1807
+ [InterceptableSpec::CbCascadedChild, :before_create],
1808
+ [InterceptableSpec::CbCascadedChild, :around_create_open],
1809
+
1810
+ [InterceptableSpec::CbCascadedChild, :around_create_close],
1811
+ [InterceptableSpec::CbCascadedChild, :after_create],
1812
+ [InterceptableSpec::CbCascadedChild, :around_save_close],
1813
+ [InterceptableSpec::CbCascadedChild, :after_save],
1814
+
1815
+ [InterceptableSpec::CbParent, :around_create_close],
1816
+ [InterceptableSpec::CbParent, :after_create],
1817
+ [InterceptableSpec::CbParent, :around_save_close],
1818
+ [InterceptableSpec::CbParent, :after_save]
1819
+ ]
1820
+ end
1799
1821
 
1800
- [InterceptableSpec::CbCascadedChild, :before_save],
1801
- [InterceptableSpec::CbCascadedChild, :around_save_open],
1802
- [InterceptableSpec::CbCascadedChild, :before_create],
1803
- [InterceptableSpec::CbCascadedChild, :around_create_open],
1822
+ it 'calls callbacks in the right order' do
1823
+ parent.save!
1824
+ expect(registry.calls).to eq expected
1825
+ end
1826
+ end
1804
1827
 
1805
- [InterceptableSpec::CbCascadedChild, :around_create_close],
1806
- [InterceptableSpec::CbCascadedChild, :after_create],
1807
- [InterceptableSpec::CbCascadedChild, :around_save_close],
1808
- [InterceptableSpec::CbCascadedChild, :after_save],
1828
+ context 'without around callbacks' do
1829
+ config_override :around_callbacks_for_embeds, false
1809
1830
 
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
1831
+ let(:expected) do
1832
+ [
1833
+ [InterceptableSpec::CbCascadedChild, :before_validation],
1834
+ [InterceptableSpec::CbCascadedChild, :after_validation],
1835
+ [InterceptableSpec::CbParent, :before_validation],
1836
+ [InterceptableSpec::CbCascadedChild, :before_validation],
1837
+ [InterceptableSpec::CbCascadedChild, :after_validation],
1838
+
1839
+ [InterceptableSpec::CbParent, :after_validation],
1840
+ [InterceptableSpec::CbParent, :before_save],
1841
+ [InterceptableSpec::CbParent, :around_save_open],
1842
+ [InterceptableSpec::CbParent, :before_create],
1843
+ [InterceptableSpec::CbParent, :around_create_open],
1844
+
1845
+ [InterceptableSpec::CbCascadedChild, :before_save],
1846
+ [InterceptableSpec::CbCascadedChild, :before_create],
1847
+
1848
+ [InterceptableSpec::CbCascadedChild, :after_create],
1849
+ [InterceptableSpec::CbCascadedChild, :after_save],
1850
+
1851
+ [InterceptableSpec::CbParent, :around_create_close],
1852
+ [InterceptableSpec::CbParent, :after_create],
1853
+ [InterceptableSpec::CbParent, :around_save_close],
1854
+ [InterceptableSpec::CbParent, :after_save]
1855
+ ]
1856
+ end
1816
1857
 
1817
- it 'calls callbacks in the right order' do
1818
- parent.save!
1819
- expect(registry.calls).to eq expected
1858
+ it 'calls callbacks in the right order' do
1859
+ parent.save!
1860
+ expect(registry.calls).to eq expected
1861
+ end
1820
1862
  end
1821
1863
  end
1822
1864
 
@@ -1879,89 +1921,180 @@ describe Mongoid::Interceptable do
1879
1921
  end
1880
1922
 
1881
1923
  context "create" do
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
- ]
1924
+ context "with around callbacks" do
1925
+ config_override :around_callbacks_for_embeds, true
1926
+
1927
+ let(:expected) do
1928
+ [
1929
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1930
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1931
+ [InterceptableSpec::CbEmbedsOneParent, :before_validation],
1932
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1933
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1934
+ [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1935
+
1936
+ [InterceptableSpec::CbEmbedsOneParent, :before_save],
1937
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
1938
+ [InterceptableSpec::CbEmbedsOneParent, :before_create],
1939
+ [InterceptableSpec::CbEmbedsOneParent, :around_create_open],
1940
+
1941
+ [InterceptableSpec::CbEmbedsOneChild, :before_save],
1942
+ [InterceptableSpec::CbEmbedsOneChild, :around_save_open],
1943
+ [InterceptableSpec::CbEmbedsOneChild, :before_create],
1944
+ [InterceptableSpec::CbEmbedsOneChild, :around_create_open],
1945
+
1946
+ [InterceptableSpec::CbEmbedsOneParent, :insert_into_database],
1947
+
1948
+ [InterceptableSpec::CbEmbedsOneChild, :around_create_close],
1949
+ [InterceptableSpec::CbEmbedsOneChild, :after_create],
1950
+ [InterceptableSpec::CbEmbedsOneChild, :around_save_close],
1951
+ [InterceptableSpec::CbEmbedsOneChild, :after_save],
1952
+
1953
+ [InterceptableSpec::CbEmbedsOneParent, :around_create_close],
1954
+ [InterceptableSpec::CbEmbedsOneParent, :after_create],
1955
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
1956
+ [InterceptableSpec::CbEmbedsOneParent, :after_save]
1957
+ ]
1958
+ end
1959
+
1960
+ it 'calls callbacks in the right order' do
1961
+ parent.save!
1962
+ expect(registry.calls).to eq expected
1963
+ end
1913
1964
  end
1914
1965
 
1915
- it 'calls callbacks in the right order' do
1916
- parent.save!
1917
- expect(registry.calls).to eq expected
1966
+ context "without around callbacks" do
1967
+ config_override :around_callbacks_for_embeds, false
1968
+
1969
+ let(:expected) do
1970
+ [
1971
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1972
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1973
+ [InterceptableSpec::CbEmbedsOneParent, :before_validation],
1974
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
1975
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
1976
+ [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1977
+
1978
+ [InterceptableSpec::CbEmbedsOneParent, :before_save],
1979
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
1980
+ [InterceptableSpec::CbEmbedsOneParent, :before_create],
1981
+ [InterceptableSpec::CbEmbedsOneParent, :around_create_open],
1982
+
1983
+ [InterceptableSpec::CbEmbedsOneChild, :before_save],
1984
+ [InterceptableSpec::CbEmbedsOneChild, :before_create],
1985
+
1986
+ [InterceptableSpec::CbEmbedsOneParent, :insert_into_database],
1987
+
1988
+ [InterceptableSpec::CbEmbedsOneChild, :after_create],
1989
+ [InterceptableSpec::CbEmbedsOneChild, :after_save],
1990
+
1991
+ [InterceptableSpec::CbEmbedsOneParent, :around_create_close],
1992
+ [InterceptableSpec::CbEmbedsOneParent, :after_create],
1993
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
1994
+ [InterceptableSpec::CbEmbedsOneParent, :after_save]
1995
+ ]
1996
+ end
1997
+
1998
+ it 'calls callbacks in the right order' do
1999
+ parent.save!
2000
+ expect(registry.calls).to eq expected
2001
+ end
1918
2002
  end
1919
2003
  end
1920
2004
 
1921
2005
  context "update" do
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
- ]
2006
+ context "with around callbacks" do
2007
+ config_override :around_callbacks_for_embeds, true
2008
+
2009
+ let(:expected) do
2010
+ [
2011
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
2012
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
2013
+ [InterceptableSpec::CbEmbedsOneParent, :before_validation],
2014
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
2015
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
2016
+ [InterceptableSpec::CbEmbedsOneParent, :after_validation],
2017
+
2018
+ [InterceptableSpec::CbEmbedsOneParent, :before_save],
2019
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
2020
+ [InterceptableSpec::CbEmbedsOneParent, :before_update],
2021
+ [InterceptableSpec::CbEmbedsOneParent, :around_update_open],
2022
+
2023
+ [InterceptableSpec::CbEmbedsOneChild, :before_save],
2024
+ [InterceptableSpec::CbEmbedsOneChild, :around_save_open],
2025
+ [InterceptableSpec::CbEmbedsOneChild, :before_update],
2026
+ [InterceptableSpec::CbEmbedsOneChild, :around_update_open],
2027
+
2028
+ [InterceptableSpec::CbEmbedsOneChild, :around_update_close],
2029
+ [InterceptableSpec::CbEmbedsOneChild, :after_update],
2030
+ [InterceptableSpec::CbEmbedsOneChild, :around_save_close],
2031
+ [InterceptableSpec::CbEmbedsOneChild, :after_save],
2032
+
2033
+ [InterceptableSpec::CbEmbedsOneParent, :around_update_close],
2034
+ [InterceptableSpec::CbEmbedsOneParent, :after_update],
2035
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
2036
+ [InterceptableSpec::CbEmbedsOneParent, :after_save]
2037
+ ]
2038
+ end
2039
+
2040
+ it 'calls callbacks in the right order' do
2041
+ parent.callback_registry = nil
2042
+ parent.child.callback_registry = nil
2043
+ parent.save!
2044
+
2045
+ parent.callback_registry = registry
2046
+ parent.child.callback_registry = registry
2047
+ parent.name = "name"
2048
+ parent.child.age = 10
2049
+
2050
+ parent.save!
2051
+ expect(registry.calls).to eq expected
2052
+ end
1951
2053
  end
1952
2054
 
1953
- it 'calls callbacks in the right order' do
1954
- parent.callback_registry = nil
1955
- parent.child.callback_registry = nil
1956
- parent.save!
2055
+ context "without around callbacks" do
2056
+ config_override :around_callbacks_for_embeds, false
1957
2057
 
1958
- parent.callback_registry = registry
1959
- parent.child.callback_registry = registry
1960
- parent.name = "name"
1961
- parent.child.age = 10
2058
+ let(:expected) do
2059
+ [
2060
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
2061
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
2062
+ [InterceptableSpec::CbEmbedsOneParent, :before_validation],
2063
+ [InterceptableSpec::CbEmbedsOneChild, :before_validation],
2064
+ [InterceptableSpec::CbEmbedsOneChild, :after_validation],
2065
+ [InterceptableSpec::CbEmbedsOneParent, :after_validation],
1962
2066
 
1963
- parent.save!
1964
- expect(registry.calls).to eq expected
2067
+ [InterceptableSpec::CbEmbedsOneParent, :before_save],
2068
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_open],
2069
+ [InterceptableSpec::CbEmbedsOneParent, :before_update],
2070
+ [InterceptableSpec::CbEmbedsOneParent, :around_update_open],
2071
+
2072
+ [InterceptableSpec::CbEmbedsOneChild, :before_save],
2073
+ [InterceptableSpec::CbEmbedsOneChild, :before_update],
2074
+
2075
+ [InterceptableSpec::CbEmbedsOneChild, :after_update],
2076
+ [InterceptableSpec::CbEmbedsOneChild, :after_save],
2077
+
2078
+ [InterceptableSpec::CbEmbedsOneParent, :around_update_close],
2079
+ [InterceptableSpec::CbEmbedsOneParent, :after_update],
2080
+ [InterceptableSpec::CbEmbedsOneParent, :around_save_close],
2081
+ [InterceptableSpec::CbEmbedsOneParent, :after_save]
2082
+ ]
2083
+ end
2084
+
2085
+ it 'calls callbacks in the right order' do
2086
+ parent.callback_registry = nil
2087
+ parent.child.callback_registry = nil
2088
+ parent.save!
2089
+
2090
+ parent.callback_registry = registry
2091
+ parent.child.callback_registry = registry
2092
+ parent.name = "name"
2093
+ parent.child.age = 10
2094
+
2095
+ parent.save!
2096
+ expect(registry.calls).to eq expected
2097
+ end
1965
2098
  end
1966
2099
  end
1967
2100
  end
@@ -2041,59 +2174,114 @@ describe Mongoid::Interceptable do
2041
2174
  end
2042
2175
  end
2043
2176
 
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
- ]
2177
+ context "with around callbacks" do
2178
+ config_override :around_callbacks_for_embeds, true
2179
+
2180
+ let(:expected) do
2181
+ [
2182
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2183
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2184
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2185
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2186
+ [InterceptableSpec::CbEmbedsManyParent, :before_validation],
2187
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2188
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2189
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2190
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2191
+ [InterceptableSpec::CbEmbedsManyParent, :after_validation],
2192
+
2193
+ [InterceptableSpec::CbEmbedsManyParent, :before_save],
2194
+ [InterceptableSpec::CbEmbedsManyParent, :around_save_open],
2195
+ [InterceptableSpec::CbEmbedsManyParent, :before_create],
2196
+ [InterceptableSpec::CbEmbedsManyParent, :around_create_open],
2197
+
2198
+ [InterceptableSpec::CbEmbedsManyChild, :before_save],
2199
+ [InterceptableSpec::CbEmbedsManyChild, :around_save_open],
2200
+ [InterceptableSpec::CbEmbedsManyChild, :before_save],
2201
+
2202
+ [InterceptableSpec::CbEmbedsManyChild, :around_save_open],
2203
+ [InterceptableSpec::CbEmbedsManyChild, :before_create],
2204
+ [InterceptableSpec::CbEmbedsManyChild, :around_create_open],
2205
+
2206
+ [InterceptableSpec::CbEmbedsManyChild, :before_create],
2207
+ [InterceptableSpec::CbEmbedsManyChild, :around_create_open],
2208
+
2209
+ [InterceptableSpec::CbEmbedsManyParent, :insert_into_database],
2210
+
2211
+ [InterceptableSpec::CbEmbedsManyChild, :around_create_close],
2212
+ [InterceptableSpec::CbEmbedsManyChild, :after_create],
2213
+
2214
+ [InterceptableSpec::CbEmbedsManyChild, :around_create_close],
2215
+ [InterceptableSpec::CbEmbedsManyChild, :after_create],
2216
+
2217
+ [InterceptableSpec::CbEmbedsManyChild, :around_save_close],
2218
+ [InterceptableSpec::CbEmbedsManyChild, :after_save],
2219
+
2220
+ [InterceptableSpec::CbEmbedsManyChild, :around_save_close],
2221
+ [InterceptableSpec::CbEmbedsManyChild, :after_save],
2222
+
2223
+ [InterceptableSpec::CbEmbedsManyParent, :around_create_close],
2224
+ [InterceptableSpec::CbEmbedsManyParent, :after_create],
2225
+ [InterceptableSpec::CbEmbedsManyParent, :around_save_close],
2226
+ [InterceptableSpec::CbEmbedsManyParent, :after_save]
2227
+ ]
2228
+ end
2229
+
2230
+ it 'calls callbacks in the right order' do
2231
+ parent.save!
2232
+ expect(registry.calls).to eq expected
2233
+ end
2092
2234
  end
2093
2235
 
2094
- it 'calls callbacks in the right order' do
2095
- parent.save!
2096
- expect(registry.calls).to eq expected
2236
+ context "without around callbacks" do
2237
+ config_override :around_callbacks_for_embeds, false
2238
+
2239
+ let(:expected) do
2240
+ [
2241
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2242
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2243
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2244
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2245
+ [InterceptableSpec::CbEmbedsManyParent, :before_validation],
2246
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2247
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2248
+ [InterceptableSpec::CbEmbedsManyChild, :before_validation],
2249
+ [InterceptableSpec::CbEmbedsManyChild, :after_validation],
2250
+ [InterceptableSpec::CbEmbedsManyParent, :after_validation],
2251
+
2252
+ [InterceptableSpec::CbEmbedsManyParent, :before_save],
2253
+ [InterceptableSpec::CbEmbedsManyParent, :around_save_open],
2254
+ [InterceptableSpec::CbEmbedsManyParent, :before_create],
2255
+ [InterceptableSpec::CbEmbedsManyParent, :around_create_open],
2256
+
2257
+ [InterceptableSpec::CbEmbedsManyChild, :before_save],
2258
+ [InterceptableSpec::CbEmbedsManyChild, :before_save],
2259
+
2260
+ [InterceptableSpec::CbEmbedsManyChild, :before_create],
2261
+
2262
+ [InterceptableSpec::CbEmbedsManyChild, :before_create],
2263
+
2264
+ [InterceptableSpec::CbEmbedsManyParent, :insert_into_database],
2265
+
2266
+ [InterceptableSpec::CbEmbedsManyChild, :after_create],
2267
+
2268
+ [InterceptableSpec::CbEmbedsManyChild, :after_create],
2269
+
2270
+ [InterceptableSpec::CbEmbedsManyChild, :after_save],
2271
+
2272
+ [InterceptableSpec::CbEmbedsManyChild, :after_save],
2273
+
2274
+ [InterceptableSpec::CbEmbedsManyParent, :around_create_close],
2275
+ [InterceptableSpec::CbEmbedsManyParent, :after_create],
2276
+ [InterceptableSpec::CbEmbedsManyParent, :around_save_close],
2277
+ [InterceptableSpec::CbEmbedsManyParent, :after_save]
2278
+ ]
2279
+ end
2280
+
2281
+ it 'calls callbacks in the right order' do
2282
+ parent.save!
2283
+ expect(registry.calls).to eq expected
2284
+ end
2097
2285
  end
2098
2286
  end
2099
2287
  end
@@ -2382,4 +2570,27 @@ describe Mongoid::Interceptable do
2382
2570
  end.to_not raise_error(ActiveModel::MissingAttributeError)
2383
2571
  end
2384
2572
  end
2573
+
2574
+ context "when around callbacks for embedded are disabled" do
2575
+ config_override :around_callbacks_for_embeds, false
2576
+
2577
+ context "when around callback is defined" do
2578
+ let(:registry) { InterceptableSpec::CallbackRegistry.new }
2579
+
2580
+ let(:parent) do
2581
+ InterceptableSpec::CbEmbedsOneParent.new(registry).tap do |parent|
2582
+ parent.child = InterceptableSpec::CbEmbedsOneChild.new(registry)
2583
+ end
2584
+ end
2585
+
2586
+ before do
2587
+ expect(Mongoid.logger).to receive(:warn).with(/Around callbacks are disabled for embedded documents/).twice.and_call_original
2588
+ expect(Mongoid.logger).to receive(:warn).with(/To enable around callbacks for embedded documents/).twice.and_call_original
2589
+ end
2590
+
2591
+ it "logs a warning" do
2592
+ parent.save!
2593
+ end
2594
+ end
2595
+ end
2385
2596
  end
@@ -195,12 +195,16 @@ 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' => 'redhat/ubi8',
207
+ 'rhel80' => 'rockylinux:8',
204
208
  }.freeze
205
209
 
206
210
  def base_image
@@ -231,6 +235,10 @@ module Mrss
231
235
  distro =~ /debian|ubuntu/
232
236
  end
233
237
 
238
+ def ubuntu?
239
+ distro=~ /ubuntu/
240
+ end
241
+
234
242
  def preload?
235
243
  !!@options[:preload]
236
244
  end
@@ -98,8 +98,8 @@ module Mrss
98
98
  def min_libmongocrypt_version(version)
99
99
  require_libmongocrypt
100
100
  before(:all) do
101
- actual_version = Gem::Version.new(Mongo::Crypt::Binding.mongocrypt_version(nil))
102
- min_version = Gem::Version.new(version)
101
+ actual_version = Utils.parse_version(Mongo::Crypt::Binding.mongocrypt_version(nil))
102
+ min_version = Utils.parse_version(version)
103
103
  unless actual_version >= min_version
104
104
  skip "libmongocrypt version #{min_version} required, but version #{actual_version} is available"
105
105
  end