Skip to content

Commit 17d560e

Browse files
bf4joaomdmoura
authored andcommitted
Account for different handling of symbol keys in Rails 4.0
Comparing as a JSON string vs. as the Hash that is convert to JSON works around the different Hash representations. This likely has to do with the introduction of config.action_dispatch.perform_deep_munge in Rails 4.1 See Rails issue 13420 1) Failure: ActiveModel::Serializer::Adapter::Json::HasManyTestTest#test_has_many_with_no_serializer [active_model_serializers/test/adapter/json/has_many_test.rb:36]: --- expected +++ actual @@ -1 +1 @@ -{:id=>42, :tags=>[{"attributes"=>{"id"=>1, "name"=>"#hash_tag"}}]} +{:id=>42, :tags=>[{"attributes"=>{:id=>1, :name=>"#hash_tag"}}]} 2) Failure: ActiveModel::Serializer::AssociationsTest#test_has_many_with_no_serializer [active_model_serializers/test/serializers/associations_test.rb:74]: --- expected +++ actual @@ -1 +1 @@ -[{"attributes"=>{"name"=>"#hashtagged"}}] +[{"attributes"=>{:name=>"#hashtagged"}}]
1 parent 741c4a4 commit 17d560e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

test/adapter/json/has_many_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_has_many_with_no_serializer
3838
tags: [
3939
{"attributes"=>{"id"=>1, "name"=>"#hash_tag"}}
4040
]
41-
}, adapter.serializable_hash[:post_with_tags])
41+
}.to_json, adapter.serializable_hash[:post_with_tags].to_json)
4242
end
4343
end
4444
end

test/serializers/associations_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def test_has_many_with_no_serializer
7171
PostWithTagsSerializer.new(@post).each_association do |name, serializer, options|
7272
assert_equal name, :tags
7373
assert_equal serializer, nil
74-
assert_equal [{ attributes: { name: "#hashtagged" }}].as_json, options[:virtual_value]
74+
assert_equal [{ attributes: { name: "#hashtagged" }}].to_json, options[:virtual_value].to_json
7575
end
7676
end
7777

0 commit comments

Comments
 (0)