mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
24 lines
612 B
Ruby
24 lines
612 B
Ruby
require 'test_helper'
|
|
|
|
module ActiveModel
|
|
class Serializer
|
|
class AttributeTest < Minitest::Test
|
|
def setup
|
|
@blog = Blog.new({ id: 1, name: 'AMS Hints' })
|
|
@blog_serializer = AlternateBlogSerializer.new(@blog)
|
|
end
|
|
|
|
def test_attributes_definition
|
|
assert_equal([:id, :title],
|
|
@blog_serializer.class._attributes)
|
|
end
|
|
|
|
def test_json_serializable_hash
|
|
adapter = ActiveModel::Serializer::Adapter::Json.new(@blog_serializer)
|
|
assert_equal({:id=>1, :title=>"AMS Hints"}, adapter.serializable_hash)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|