Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
beauby committed Oct 9, 2015
1 parent 9f0938c commit c0dc25c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/serializers/inline_serializers_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module ActiveModel
class Serializer
class InlineSerializersTest < Minitest::Test
class PostSerializer < ActiveModel::Serializer
attributes :title, :body
belongs_to :author
has_many :comments do
attributes :body
belongs_to :author
end
end

def test_inline_serializer_defined_if_block_given
refute_nil("#{self.class}::PostSerializer::CommentSerializer".safe_constantize)
assert_equal(ActiveModel::Serializer, PostSerializer::CommentSerializer.superclass)
assert_equal([:author], PostSerializer::CommentSerializer._reflections.map(&:name))
assert_equal([:body], PostSerializer::CommentSerializer._attributes)
end

def test_inline_serializer_not_defined_unless_block_given
assert_nil("#{self.class}::PostSerializer::AuthorSerializer".safe_constantize)
end
end
end
end

0 comments on commit c0dc25c

Please sign in to comment.