First try to implement ArraySerializer

This commit is contained in:
Tema Bolshakov
2014-08-28 19:16:24 +04:00
parent 1b718b6d48
commit c1fdfc1cdc
6 changed files with 46 additions and 45 deletions

View File

@@ -3,10 +3,6 @@ require 'test_helper'
module ActiveModel
class Serializer
class AssocationsTest < Minitest::Test
def def_serializer(&block)
Class.new(ActiveModel::Serializer, &block)
end
class Model
def initialize(hash={})
@attributes = hash
@@ -26,19 +22,7 @@ module ActiveModel
end
end
end
Post = Class.new(Model)
Comment = Class.new(Model)
PostSerializer = Class.new(ActiveModel::Serializer) do
attributes :title, :body
has_many :comments
end
CommentSerializer = Class.new(ActiveModel::Serializer) do
attributes :id, :body
belongs_to :post
end
def setup
@post = Post.new({ title: 'New Post', body: 'Body' })