Allow to embed nothing but still side loading

Closes #361, #399, #401
This commit is contained in:
Santiago Pastorino
2013-10-24 13:24:24 -02:00
parent df5ef33ae6
commit 5c6541145a
3 changed files with 17 additions and 3 deletions

View File

@@ -98,6 +98,20 @@ module ActiveModel
CONFIG.clear
end
def test_associations_embedding_nothing_including_objects_serialization_using_as_json
CONFIG.embed = nil
CONFIG.include = true
PostSerializer._associations[:comments].send :initialize, @association.name, @association.options
assert_equal({
'post' => { title: 'Title 1', body: 'Body 1' },
'comments' => [{ content: 'C1' }, { content: 'C2' }]
}, @post_serializer.as_json)
ensure
CONFIG.clear
end
def test_associations_using_a_given_serializer
@association.embed_in_root = true
@post_serializer.root = nil