File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ module ActiveModel
2+ class Serializer
3+ class InlineSerializersTest < Minitest ::Test
4+ class PostSerializer < ActiveModel ::Serializer
5+ attributes :title , :body
6+ belongs_to :author
7+ has_many :comments do
8+ attributes :body
9+ belongs_to :author
10+ end
11+ end
12+
13+ def test_inline_serializer_defined_if_block_given
14+ refute_nil ( "#{ self . class } ::PostSerializer::CommentSerializer" . safe_constantize )
15+ assert_equal ( ActiveModel ::Serializer , PostSerializer ::CommentSerializer . superclass )
16+ assert_equal ( [ :author ] , PostSerializer ::CommentSerializer . _reflections . map ( &:name ) )
17+ assert_equal ( [ :body ] , PostSerializer ::CommentSerializer . _attributes )
18+ end
19+
20+ def test_inline_serializer_not_defined_unless_block_given
21+ assert_nil ( "#{ self . class } ::PostSerializer::AuthorSerializer" . safe_constantize )
22+ end
23+ end
24+ end
25+ end
You can’t perform that action at this time.
0 commit comments