diff --git a/lib/redmine/safe_attributes.rb b/lib/redmine/safe_attributes.rb index 8c49a437..13db6a45 100644 --- a/lib/redmine/safe_attributes.rb +++ b/lib/redmine/safe_attributes.rb @@ -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 diff --git a/test/unit/lib/redmine/safe_attributes_test.rb b/test/unit/lib/redmine/safe_attributes_test.rb index bfad6606..195b4446 100644 --- a/test/unit/lib/redmine/safe_attributes_test.rb +++ b/test/unit/lib/redmine/safe_attributes_test.rb @@ -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