[#282] Make safe_attributes work with symbol keys
This commit is contained in:
parent
b5b3684473
commit
0320517d2c
@ -67,7 +67,7 @@ module Redmine
|
||||
# # => {'title' => 'My book'}
|
||||
def delete_unsafe_attributes(attrs, user=User.current)
|
||||
safe = safe_attribute_names(user)
|
||||
attrs.dup.delete_if {|k,v| !safe.include?(k)}
|
||||
attrs.dup.delete_if {|k,v| !safe.include?(k.to_s)}
|
||||
end
|
||||
|
||||
# Sets attributes from attrs that are safe
|
||||
|
@ -90,6 +90,13 @@ class Redmine::SafeAttributesTest < ActiveSupport::TestCase
|
||||
assert_equal 'jsmith', p.login
|
||||
end
|
||||
|
||||
def test_with_indifferent_access
|
||||
p = Person.new
|
||||
p.safe_attributes = {'firstname' => 'Jack', :lastname => 'Miller'}
|
||||
assert_equal 'Jack', p.firstname
|
||||
assert_equal 'Miller', p.lastname
|
||||
end
|
||||
|
||||
def test_use_safe_attributes_in_subclasses
|
||||
b = Book.new
|
||||
p = PublishedBook.new
|
||||
|
Loading…
x
Reference in New Issue
Block a user