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

47
test/fixtures/poro.rb vendored
View File

@@ -7,30 +7,39 @@ class Model
@attributes[name]
end
def model
@model ||= Model.new(attr1: 'v1', attr2: 'v2')
end
def id
object_id
end
end
class ModelSerializer < ActiveModel::Serializer
def attr2
attr2 = object.read_attribute_for_serialization(:attr2)
if scope
attr2 + '-' + scope
else
attr2
end
###
## Models
###
class User < Model
def profile
@profile ||= Profile.new(name: 'N1', description: 'D1')
end
end
class Profile < Model
end
###
## Serializers
###
class UserSerializer < ActiveModel::Serializer
attributes :name, :email
has_one :profile
end
class ProfileSerializer < ActiveModel::Serializer
def description
description = object.read_attribute_for_serialization(:description)
scope ? "#{description} - #{scope}" : description
end
attributes :attr1, :attr2
end
class AnotherSerializer < ActiveModel::Serializer
attributes :attr2, :attr3
has_one :model
attributes :name, :description
end