Test for SimpleAdapter#serializable_hash

This commit is contained in:
Tema Bolshakov 2014-08-27 09:15:07 +04:00
parent 553c470e10
commit 7b7d4d8907
2 changed files with 10 additions and 2 deletions

View File

@ -2,10 +2,14 @@ module ActiveModel
class Serializer
class Adapter
class SimpleAdapter < Adapter
def to_json(options={})
def serializable_hash(options = {})
serializer.attributes.each_with_object({}) do |(attr, value), h|
h[attr] = value
end.to_json # FIXME: why does passing options here cause {}?
end
end
def to_json(options={})
serializable_hash(options).to_json
end
end
end

View File

@ -11,6 +11,10 @@ module ActiveModel
@adapter = SimpleAdapter.new(@profile_serializer)
end
def test_serializable_hash
assert_equal({name: 'Name 1', description: 'Description 1'}, @adapter.serializable_hash)
end
def test_simple_adapter
assert_equal('{"name":"Name 1","description":"Description 1"}',
@adapter.to_json)