Extract attributes filtering from serializer into adapter.

This commit is contained in:
Lucas Hosseini
2015-10-05 06:08:11 +02:00
parent 066990184b
commit 658810e6a0
8 changed files with 35 additions and 59 deletions

View File

@@ -4,22 +4,11 @@ module ActiveModel
class Serializer
class FieldsetTest < Minitest::Test
def test_fieldset_with_hash
fieldset = ActiveModel::Serializer::Fieldset.new({ 'post' => %w(id title), 'coment' => ['body'] })
fieldset = ActiveModel::Serializer::Fieldset.new('post' => %w(id title), 'comment' => ['body'])
expected = { :post => [:id, :title], :comment => [: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
)
assert_equal(expected, fieldset.fields)
end
end
end
end
end