Support strings as attribute names

When generating the `_fast_attributes` method, attribute names that
could not be represented as symbols (at least without escaping) would
throw parsing errors.
This commit is contained in:
vanstee
2013-04-08 20:21:57 -04:00
parent ab5d40f38b
commit a900d31041
3 changed files with 20 additions and 1 deletions

View File

@@ -51,6 +51,17 @@ class SerializerTest < ActiveModel::TestCase
}, hash)
end
def test_attributes_method_with_unsymbolizable_key
user = User.new
user_serializer = UserAttributesWithUnsymbolizableKeySerializer.new(user, :scope => {})
hash = user_serializer.as_json
assert_equal({
:user_attributes_with_unsymbolizable_key => { :first_name => "Jose", :"last-name" => "Valim", :ok => true }
}, hash)
end
def test_attribute_method_with_name_as_serializer_prefix
object = SomeObject.new("something")
object_serializer = SomeSerializer.new(object, {})