diff --git a/.travis.yml b/.travis.yml index 776b220f..c49ff981 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,13 @@ rvm: - ruby-head - jruby-19mode - rbx-2 + - ruby-head sudo: false +install: + - bundle install --retry=3 + env: - "RAILS_VERSION=3.2.17" - "RAILS_VERSION=4.0.3" diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index 7a6ee7ca..01b439e7 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -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 diff --git a/test/integration/action_controller/namespaced_serialization_test.rb b/test/integration/action_controller/namespaced_serialization_test.rb index 1e758d29..4e29f77c 100644 --- a/test/integration/action_controller/namespaced_serialization_test.rb +++ b/test/integration/action_controller/namespaced_serialization_test.rb @@ -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 \ No newline at end of file +end