@@ -16,6 +16,10 @@ def dump_schema_information
1616 original_dump_schema_information
1717 end
1818
19+ def dump_schema_versions
20+ original_dump_schema_information
21+ end
22+
1923 def original_dump_schema_information ; end
2024 end
2125
@@ -26,22 +30,45 @@ def original_dump_schema_information; end
2630
2731 let ( :instance ) { instance_class . new }
2832
29- it 'calls SchemaMigrations touch_all and skips original implementation' do
30- allow ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to receive ( :touch_all )
31- allow ( instance ) . to receive ( :original_dump_schema_information )
33+ context 'when using Rails >= 8.1' , if : Rails . gem_version >= Gem ::Version . create ( '8.1' ) do
34+ it 'calls SchemaMigrations touch_all and skips original implementation' do
35+ allow ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to receive ( :touch_all )
36+ allow ( instance ) . to receive ( :original_dump_schema_information )
37+
38+ instance . dump_schema_versions
39+
40+ expect ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to have_received ( :touch_all ) . with ( instance )
41+ expect ( instance ) . not_to have_received ( :original_dump_schema_information )
42+ end
43+
44+ it 'does not call touch_all in production' do
45+ allow ( Rails ) . to receive ( :env ) . and_return ( ActiveSupport ::StringInquirer . new ( 'production' ) )
46+ allow ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to receive ( :touch_all )
3247
33- instance . dump_schema_information
48+ instance . dump_schema_versions
3449
35- expect ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to have_received ( :touch_all ) . with ( instance )
36- expect ( instance ) . not_to have_received ( :original_dump_schema_information )
50+ expect ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . not_to have_received ( :touch_all )
51+ end
3752 end
3853
39- it 'does not call touch_all in production' do
40- allow ( Rails ) . to receive ( :env ) . and_return ( ActiveSupport ::StringInquirer . new ( 'production' ) )
41- allow ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to receive ( :touch_all )
54+ context 'when using Rails < 8.1' , if : Rails . gem_version < Gem ::Version . create ( '8.1' ) do
55+ it 'calls SchemaMigrations touch_all and skips original implementation' do
56+ allow ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to receive ( :touch_all )
57+ allow ( instance ) . to receive ( :original_dump_schema_information )
58+
59+ instance . dump_schema_information
60+
61+ expect ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to have_received ( :touch_all ) . with ( instance )
62+ expect ( instance ) . not_to have_received ( :original_dump_schema_information )
63+ end
64+
65+ it 'does not call touch_all in production' do
66+ allow ( Rails ) . to receive ( :env ) . and_return ( ActiveSupport ::StringInquirer . new ( 'production' ) )
67+ allow ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . to receive ( :touch_all )
4268
43- instance . dump_schema_information
69+ instance . dump_schema_information
4470
45- expect ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . not_to have_received ( :touch_all )
71+ expect ( Code0 ::ZeroTrack ::Database ::SchemaMigrations ) . not_to have_received ( :touch_all )
72+ end
4673 end
4774end
0 commit comments