allow id attribute to be overriden

This commit is contained in:
Josh Lane
2015-08-04 09:22:05 -07:00
parent c4af610ed2
commit f6e3d4e1f9
2 changed files with 15 additions and 3 deletions

View File

@@ -33,6 +33,15 @@ module ActiveModel
assert_equal([:title], serializer_class._attributes)
end
def test_id_attribute_override
serializer = Class.new(ActiveModel::Serializer) do
attribute :name, key: :id
end
adapter = ActiveModel::Serializer::Adapter::Json.new(serializer.new(@blog))
assert_equal({ blog: { id: "AMS Hints" } }, adapter.serializable_hash)
end
end
end
end