Commit 0320517d authored by Gregor Schmidt's avatar Gregor Schmidt

[#282] Make safe_attributes work with symbol keys

parent b5b36844
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment