mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 06:46:50 +00:00
In the test, use the same :hash across serializers
Otherwise, `include!` will not remember the unique_values of already-sideloaded hashes across serializer calls.
This commit is contained in:
parent
6be6ed8326
commit
28ee88ca9a
@ -30,6 +30,9 @@ class AssociationTest < ActiveModel::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
|
@hash = {}
|
||||||
|
@root_hash = {}
|
||||||
|
|
||||||
@post = Model.new(:title => "New Post", :body => "Body")
|
@post = Model.new(:title => "New Post", :body => "Body")
|
||||||
@comment = Model.new(:id => 1, :body => "ZOMG A COMMENT")
|
@comment = Model.new(:id => 1, :body => "ZOMG A COMMENT")
|
||||||
@post.comments = [ @comment ]
|
@post.comments = [ @comment ]
|
||||||
@ -43,17 +46,13 @@ class AssociationTest < ActiveModel::TestCase
|
|||||||
attributes :title, :body
|
attributes :title, :body
|
||||||
end
|
end
|
||||||
|
|
||||||
@post_serializer = @post_serializer_class.new(@post)
|
@post_serializer = @post_serializer_class.new(@post, :hash => @root_hash)
|
||||||
|
|
||||||
@hash = {}
|
|
||||||
@root_hash = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def include!(key, options={})
|
def include!(key, options={})
|
||||||
@post_serializer.include! key, {
|
@post_serializer.include! key, {
|
||||||
:embed => :ids,
|
:embed => :ids,
|
||||||
:include => true,
|
:include => true,
|
||||||
:hash => @root_hash,
|
|
||||||
:node => @hash,
|
:node => @hash,
|
||||||
:serializer => @comment_serializer_class
|
:serializer => @comment_serializer_class
|
||||||
}.merge(options)
|
}.merge(options)
|
||||||
@ -61,7 +60,6 @@ class AssociationTest < ActiveModel::TestCase
|
|||||||
|
|
||||||
def include_bare!(key, options={})
|
def include_bare!(key, options={})
|
||||||
@post_serializer.include! key, {
|
@post_serializer.include! key, {
|
||||||
:hash => @root_hash,
|
|
||||||
:node => @hash,
|
:node => @hash,
|
||||||
:serializer => @comment_serializer_class
|
:serializer => @comment_serializer_class
|
||||||
}.merge(options)
|
}.merge(options)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user