mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Rename ForbiddenAttributes exception to ForbiddenAttributesError
This commit is contained in:
parent
4b608c009e
commit
1fa4f9243d
4 changed files with 5 additions and 5 deletions
|
@ -1,11 +1,11 @@
|
|||
module ActiveModel
|
||||
class ForbiddenAttributes < StandardError
|
||||
class ForbiddenAttributesError < StandardError
|
||||
end
|
||||
|
||||
module ForbiddenAttributesProtection
|
||||
def sanitize_for_mass_assignment(attributes, options = {})
|
||||
if attributes.respond_to?(:permitted?) && !attributes.permitted?
|
||||
raise ActiveModel::ForbiddenAttributes
|
||||
raise ActiveModel::ForbiddenAttributesError
|
||||
else
|
||||
attributes
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ end
|
|||
class ActiveModelMassUpdateProtectionTest < ActiveSupport::TestCase
|
||||
test "forbidden attributes cannot be used for mass updating" do
|
||||
params = ProtectedParams.new({ "a" => "b" })
|
||||
assert_raises(ActiveModel::ForbiddenAttributes) do
|
||||
assert_raises(ActiveModel::ForbiddenAttributesError) do
|
||||
Account.new.sanitize_for_mass_assignment(params)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module ActiveRecord
|
|||
# matching the attribute names (which again matches the column names).
|
||||
#
|
||||
# If the passed hash responds to permitted? method and the return value
|
||||
# of this method is false an ActiveModel::ForbiddenAttributes exception
|
||||
# of this method is false an ActiveModel::ForbiddenAttributesError exception
|
||||
# is raised.
|
||||
def attributes=(new_attributes)
|
||||
return unless new_attributes.is_a?(Hash)
|
||||
|
|
|
@ -26,7 +26,7 @@ end
|
|||
class ForbiddenAttributesProtectionTest < ActiveRecord::TestCase
|
||||
def test_forbidden_attributes_cannot_be_used_for_mass_assignment
|
||||
params = ProtectedParams.new(first_name: 'Guille', gender: 'm')
|
||||
assert_raises(ActiveModel::ForbiddenAttributes) do
|
||||
assert_raises(ActiveModel::ForbiddenAttributesError) do
|
||||
Person.new(params)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue