Skip to content

Commit 6e85aec

Browse files
committed
Fix the remaining specs that include normalization
1 parent 5e2fe34 commit 6e85aec

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

spec/modelscope/integration/attribute_generated_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# frozen_string_literal: true
22

33
RSpec.describe CallbackHell, "with attribute-generated callbacks and validations" do
4+
def normalization_supported?
5+
ActiveRecord::Base.respond_to?(:normalizes)
6+
end
47
subject(:foo) { CallbackHell::Collector.new(Foo, mode: :full).collect }
58
subject(:bar) { CallbackHell::Collector.new(Bar, mode: :full).collect }
69

710
it "correctly marks the callbacks generated by attributes" do
11+
skip "Normalization not supported in this Rails version" unless normalization_supported?
812
expect(foo).to have_callback(
913
callback_name: :before_validate,
1014
method_name: :cant_modify_encrypted_attributes_when_frozen,

spec/modelscope/integration/empty_activerecord_spec.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# frozen_string_literal: true
22

33
RSpec.describe CallbackHell, "with an empty ActiveRecord" do
4+
def normalization_supported?
5+
ActiveRecord::Base.respond_to?(:normalizes)
6+
end
7+
48
let(:options) { {} }
59
subject(:ar) { CallbackHell::Collector.new(ApplicationRecord, **options).collect }
610

@@ -18,10 +22,12 @@
1822
method_name: :cant_modify_encrypted_attributes_when_frozen,
1923
origin: :rails, inherited: false
2024
)
21-
expect(ar).to have_callback(
22-
method_name: :normalize_changed_in_place_attributes,
23-
origin: :rails, inherited: false
24-
)
25+
if normalization_supported?
26+
expect(ar).to have_callback(
27+
method_name: :normalize_changed_in_place_attributes,
28+
origin: :rails, inherited: false
29+
)
30+
end
2531
end
2632
end
2733
end

0 commit comments

Comments
 (0)