added failing spec to show how both symbol and string keys are causing problems

This commit is contained in:
Kevin Bullaughey
2014-09-21 07:40:55 -04:00
parent 89f87bf855
commit 34d684ee9a
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
require 'test_helper'
module ActiveModel
class Serializer
class HasOneAndHasManyTest < Minitest::Test
def setup
@post = SpecialPost.new({ title: 'T1', body: 'B1'})
@post_serializer = SpecialPostSerializer.new(@post)
end
def teardown
end
def test_side_load_has_one_and_has_many_in_same_array
assert_equal({
"post" => {
title: 'T1',
body: 'B1',
'comment_ids' => @post.comments.map { |c| c.object_id },
'special_comment_id' => @post_serializer.special_comment.object_id,
},
"comments" => [{ content: 'C1' }, { content: 'C2' }, { content: 'special' }]
}, @post_serializer.as_json(root: 'post'))
end
end
end
end