Skip to content

Commit 6dd4579

Browse files
authored
Merge pull request rails#48917 from Shopify/use-AR-deprecator-instead-of-AM
Use `ActiveRecord.deprecator` for the alias attribute deprecation
2 parents 008db52 + 594f539 commit 6dd4579

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

activerecord/lib/active_record/attribute_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def alias_attribute_method_definition(code_generator, pattern, new_name, old_nam
9393
aliased_method_redefined_as_well = method_defined_within?(method_name, self)
9494
return if aliased_method_redefined_as_well
9595

96-
ActiveModel.deprecator.warn(
96+
ActiveRecord.deprecator.warn(
9797
"#{self} model aliases `#{old_name}` and has a method called `#{target_name}` defined. " \
9898
"Starting in Rails 7.2 `#{method_name}` will not be calling `#{target_name}` anymore. " \
9999
"You may want to additionally define `#{method_name}` to preserve the current behavior."

activerecord/test/cases/attribute_methods_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ def title_was
11771177
You may want to additionally define `subject_was` to preserve the current behavior.
11781178
MESSAGE
11791179

1180-
obj = assert_deprecated(message, ActiveModel.deprecator) do
1180+
obj = assert_deprecated(message, ActiveRecord.deprecator) do
11811181
ClassWithDeprecatedAliasAttributeBehavior.new
11821182
end
11831183
obj.title = "hey"
@@ -1204,7 +1204,7 @@ def title_was
12041204
You may want to additionally define `subject_was` to preserve the current behavior.
12051205
MESSAGE
12061206

1207-
obj = assert_deprecated(message, ActiveModel.deprecator) do
1207+
obj = assert_deprecated(message, ActiveRecord.deprecator) do
12081208
ClassWithDeprecatedAliasAttributeBehaviorFromModule.new
12091209
end
12101210
obj.title = "hey"
@@ -1226,7 +1226,7 @@ def subject_was
12261226
end
12271227

12281228
test "#alias_attribute with an overridden original method along with an overridden alias method doesn't issue a deprecation" do
1229-
obj = assert_not_deprecated(ActiveModel.deprecator) do
1229+
obj = assert_not_deprecated(ActiveRecord.deprecator) do
12301230
ClassWithDeprecatedAliasAttributeBehaviorResolved.new
12311231
end
12321232
obj.title = "hey"

0 commit comments

Comments
 (0)