fixed issue with rendering Hash which appears in rails 4.2.0.beta4

This commit is contained in:
Roman Greshny 2014-11-05 16:34:08 +02:00
parent cd1829d0c0
commit 4b49d1b132
2 changed files with 11 additions and 2 deletions

View File

@ -56,7 +56,7 @@ end
attr_reader :key_format
def serializer_for(resource, options = {})
if resource.respond_to?(:each)
if resource.respond_to?(:each) && !resource.is_a?(Hash)
if Object.constants.include?(:ArraySerializer)
::ArraySerializer
else

View File

@ -19,6 +19,10 @@ module ActionController
def render_comments
render json: [Comment.new(content: 'Comment 1')]
end
def render_hash
render json: {message: 'not found'}, status: 404
end
end
tests TestNamespace::MyController
@ -42,6 +46,11 @@ module ActionController
get :render_comments
assert_serializer CommentSerializer
end
def test_render_hash_regression
get :render_hash
assert_equal JSON.parse(response.body), {'message' => 'not found'}
end
end
class OptionNamespacedSerializationTest < ActionController::TestCase
@ -93,4 +102,4 @@ module ActionController
end
end
end
end