Skip to content

Commit 5e2fe34

Browse files
committed
Fixing normalization specs for Rails 7.0 and 7.2
1 parent f35c67b commit 5e2fe34

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/callback_hell/analyzers/callback_analyzer.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ class CallbackAnalyzer
1010
].freeze
1111

1212
RAILS_ATTRIBUTE_OWNERS = [
13-
defined?(ActiveRecord::Normalization) ? ActiveRecord::Normalization : ActiveModel::Attributes::Normalization,
14-
ActiveRecord::Encryption::EncryptableRecord
15-
].freeze
13+
defined?(ActiveRecord::Normalization) &&
14+
ActiveRecord::Normalization,
15+
defined?(ActiveModel::Attributes::Normalization) &&
16+
ActiveModel::Attributes::Normalization,
17+
defined?(ActiveRecord::Encryption::EncryptableRecord) &&
18+
ActiveRecord::Encryption::EncryptableRecord
19+
].compact.freeze
1620

1721
def initialize(callback, model, defining_class)
1822
@callback = callback

spec/internal/app/models/foo.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Foo < ApplicationRecord
1414
after_create :noop
1515
around_create :noop, if: :createable?
1616

17-
normalizes :name, with: -> { _1.strip }
17+
normalizes :name, with: -> { _1.strip } if respond_to?(:normalizes)
1818

1919
def noop = true
2020

0 commit comments

Comments
 (0)