Extend dangerous attribute methods with dangerous methods from Object
This commit is contained in:
parent
fd9308a292
commit
4c62903dfb
@ -33,7 +33,8 @@ def dangerous_attribute_methods # :nodoc:
|
||||
Base.instance_methods +
|
||||
Base.private_instance_methods -
|
||||
Base.superclass.instance_methods -
|
||||
Base.superclass.private_instance_methods
|
||||
Base.superclass.private_instance_methods +
|
||||
%i[__id__ dup freeze hash object_id class clone]
|
||||
).map { |m| -m.to_s }.to_set.freeze
|
||||
end
|
||||
end
|
||||
|
@ -651,8 +651,8 @@ def topic.approved; false; end
|
||||
assert_predicate topic, :is_test?
|
||||
end
|
||||
|
||||
test "raises ActiveRecord::DangerousAttributeError when defining an AR method in a model" do
|
||||
%w(save create_or_update).each do |method|
|
||||
test "raises ActiveRecord::DangerousAttributeError when defining an AR method or dangerous Object method in a model" do
|
||||
%w(save create_or_update hash dup).each do |method|
|
||||
klass = Class.new(ActiveRecord::Base)
|
||||
klass.class_eval "def #{method}() 'defined #{method}' end"
|
||||
assert_raise ActiveRecord::DangerousAttributeError do
|
||||
|
Loading…
Reference in New Issue
Block a user