active_model_serializers/test/unit/active_model/serializer/meta_test.rb
Adrian Mugnolo and Santiago Pastorino 1a26a089d5 Split Configuration object
2014-01-16 13:38:50 -02:00

40 lines
988 B
Ruby

require 'test_helper'
module ActiveModel
class Serializer
class MetaTest < Minitest::Test
def setup
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
end
def test_meta
profile_serializer = ProfileSerializer.new(@profile, root: 'profile', meta: { total: 10 })
assert_equal({
'profile' => {
name: 'Name 1',
description: 'Description 1'
},
meta: {
total: 10
}
}, profile_serializer.as_json)
end
def test_meta_using_meta_key
profile_serializer = ProfileSerializer.new(@profile, root: 'profile', meta_key: :my_meta, meta: { total: 10 })
assert_equal({
'profile' => {
name: 'Name 1',
description: 'Description 1'
},
my_meta: {
total: 10
}
}, profile_serializer.as_json)
end
end
end
end