mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
25 lines
624 B
Ruby
25 lines
624 B
Ruby
require 'test_helper'
|
|
|
|
module ActiveModel
|
|
class Serializer
|
|
class FieldsetTest < Minitest::Test
|
|
def test_fieldset_with_hash
|
|
fieldset = ActiveModel::Serializer::Fieldset.new({ 'post' => %w(id title), 'coment' => ['body'] })
|
|
|
|
assert_equal(
|
|
{ :post => [:id, :title], :coment => [:body] },
|
|
fieldset.fields
|
|
)
|
|
end
|
|
|
|
def test_fieldset_with_array_of_fields_and_root_name
|
|
fieldset = ActiveModel::Serializer::Fieldset.new(['title'], 'post')
|
|
|
|
assert_equal(
|
|
{ :post => [:title] },
|
|
fieldset.fields
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end |