mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 23:06:50 +00:00
fix tests, but need to understand how the serializer class attribute _associations was getting changed.
This commit is contained in:
parent
39bee48ae6
commit
34f08477e4
@ -7,19 +7,13 @@ module ActiveModel
|
|||||||
class FieldsetTest < Minitest::Test
|
class FieldsetTest < Minitest::Test
|
||||||
def setup
|
def setup
|
||||||
@post = Post.new(title: 'New Post', body: 'Body')
|
@post = Post.new(title: 'New Post', body: 'Body')
|
||||||
@first_comment = Comment.new(id: 1, body: 'ZOMG A COMMENT')
|
comment_1 = Comment.new(id: 1, body: 'comment one')
|
||||||
@second_comment = Comment.new(id: 2, body: 'ZOMG ANOTHER COMMENT')
|
comment_2 = Comment.new(id: 2, body: 'comment two')
|
||||||
@post.comments = [@first_comment, @second_comment]
|
@post.comments = [comment_1, comment_2]
|
||||||
@first_comment.post = @post
|
|
||||||
@second_comment.post = @post
|
|
||||||
|
|
||||||
@serializer = PostSerializer.new(@post)
|
@serializer = PostSerializer.new(@post)
|
||||||
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer)
|
@adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer)
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
@serializer = nil
|
|
||||||
@adapter = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_fieldset_with_fields_array
|
def test_fieldset_with_fields_array
|
||||||
@ -44,9 +38,13 @@ module ActiveModel
|
|||||||
fieldset = ActiveModel::Serializer::Fieldset.new(@serializer, {post: [:title], comment: [:body]})
|
fieldset = ActiveModel::Serializer::Fieldset.new(@serializer, {post: [:title], comment: [:body]})
|
||||||
|
|
||||||
assert_equal(
|
assert_equal(
|
||||||
[{:body=>"ZOMG A COMMENT" }, {:body=>"ZOMG ANOTHER COMMENT"}],
|
[{:body=>"comment one" }, {:body=>"comment two"}],
|
||||||
@adapter.serializable_hash({fieldset: fieldset})[:linked][:comments]
|
@adapter.serializable_hash({fieldset: fieldset})[:linked][:comments]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#don't understand how this is getting set.
|
||||||
|
@serializer.class._associations[:comments][:options] = {}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user