Skip to content

Commit 336c720

Browse files
authored
Merge pull request rails#46394 from dsusviela/add_frozen_to_dangerous_methods
Add frozen to dangerous methods
2 parents 32957f3 + 7e5c5a2 commit 336c720

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

activerecord/lib/active_record/attribute_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def dangerous_attribute_methods # :nodoc:
3434
Base.private_instance_methods -
3535
Base.superclass.instance_methods -
3636
Base.superclass.private_instance_methods +
37-
%i[__id__ dup freeze hash object_id class clone]
37+
%i[__id__ dup freeze frozen? hash object_id class clone]
3838
).map { |m| -m.to_s }.to_set.freeze
3939
end
4040
end

activerecord/test/cases/attribute_methods_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ def topic.approved; false; end
662662
end
663663

664664
test "raises ActiveRecord::DangerousAttributeError when defining an AR method or dangerous Object method in a model" do
665-
%w(save create_or_update hash dup).each do |method|
665+
%w(save create_or_update hash dup frozen?).each do |method|
666666
klass = Class.new(ActiveRecord::Base)
667667
klass.class_eval "def #{method}() 'defined #{method}' end"
668668
assert_raise ActiveRecord::DangerousAttributeError do

0 commit comments

Comments
 (0)