From 34f08477e4cc6838668a5a87fe3f61460bac5164 Mon Sep 17 00:00:00 2001 From: Aaron Renoir Date: Sun, 26 Oct 2014 14:41:14 -0700 Subject: [PATCH] fix tests, but need to understand how the serializer class attribute _associations was getting changed. --- test/adapter/json_api/fieldset_test.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/adapter/json_api/fieldset_test.rb b/test/adapter/json_api/fieldset_test.rb index 03619724..ded4e4a9 100644 --- a/test/adapter/json_api/fieldset_test.rb +++ b/test/adapter/json_api/fieldset_test.rb @@ -7,19 +7,13 @@ module ActiveModel class FieldsetTest < Minitest::Test def setup @post = Post.new(title: 'New Post', body: 'Body') - @first_comment = Comment.new(id: 1, body: 'ZOMG A COMMENT') - @second_comment = Comment.new(id: 2, body: 'ZOMG ANOTHER COMMENT') - @post.comments = [@first_comment, @second_comment] - @first_comment.post = @post - @second_comment.post = @post + comment_1 = Comment.new(id: 1, body: 'comment one') + comment_2 = Comment.new(id: 2, body: 'comment two') + @post.comments = [comment_1, comment_2] @serializer = PostSerializer.new(@post) @adapter = ActiveModel::Serializer::Adapter::JsonApi.new(@serializer) - end - def teardown - @serializer = nil - @adapter = nil end def test_fieldset_with_fields_array @@ -44,9 +38,13 @@ module ActiveModel fieldset = ActiveModel::Serializer::Fieldset.new(@serializer, {post: [:title], comment: [:body]}) assert_equal( - [{:body=>"ZOMG A COMMENT" }, {:body=>"ZOMG ANOTHER COMMENT"}], + [{:body=>"comment one" }, {:body=>"comment two"}], @adapter.serializable_hash({fieldset: fieldset})[:linked][:comments] ) + + #don't understand how this is getting set. + @serializer.class._associations[:comments][:options] = {} + end end