mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
fixed issue with rendering Hash which appears in rails 4.2.0.beta4
This commit is contained in:
parent
cd1829d0c0
commit
4b49d1b132
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user