Use more meaningful model names for tests

This commit is contained in:
Santiago Pastorino
2013-08-16 19:16:46 -03:00
parent 516f5bdceb
commit 4c7599cfff
7 changed files with 102 additions and 104 deletions

View File

@@ -1,40 +1,39 @@
require 'test_helper'
require 'active_model/serializer'
module ActiveModel
class Serializer
class MetaTest < ActiveModel::TestCase
def setup
@model = ::Model.new({ :attr1 => 'value1', :attr2 => 'value2', :attr3 => 'value3' })
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
end
def test_meta
model_serializer = ModelSerializer.new(@model, root: 'model', meta: { 'total' => 10 })
profile_serializer = ProfileSerializer.new(@profile, root: 'profile', meta: { 'total' => 10 })
assert_equal({
'model' => {
'attr1' => 'value1',
'attr2' => 'value2'
'profile' => {
'name' => 'Name 1',
'description' => 'Description 1'
},
'meta' => {
'total' => 10
}
}, model_serializer.as_json)
}, profile_serializer.as_json)
end
def test_meta_using_meta_key
model_serializer = ModelSerializer.new(@model, root: 'model', meta_key: :my_meta, my_meta: { 'total' => 10 })
profile_serializer = ProfileSerializer.new(@profile, root: 'profile', meta_key: :my_meta, my_meta: { 'total' => 10 })
assert_equal({
'model' => {
'attr1' => 'value1',
'attr2' => 'value2'
'profile' => {
'name' => 'Name 1',
'description' => 'Description 1'
},
'my_meta' => {
'total' => 10
}
}, model_serializer.as_json)
}, profile_serializer.as_json)
end
end
end