Make render json work when not using AMS

This commit is contained in:
Santiago Pastorino 2013-09-14 20:31:36 -03:00
parent 7405baafd7
commit 8462a73f3a
2 changed files with 18 additions and 0 deletions

View File

@ -68,6 +68,8 @@ module ActionController
options.delete(:serializer) ||
ActiveModel::Serializer.serializer_for(resource)
return unless serializer
options[:scope] = serialization_scope unless options.has_key?(:scope)
serializer.new(resource, options)

View File

@ -115,5 +115,21 @@ module ActionController
assert_equal '{"name":"Name 1","description":"Description 1 - current_user"}', @response.body
end
end
class RailsSerializerTest < ActionController::TestCase
class MyController < ActionController::Base
def render_using_rails_behavior
render json: JSON.dump(hello: 'world')
end
end
tests MyController
def test_render_using_rails_behavior
get :render_using_rails_behavior
assert_equal 'application/json', @response.content_type
assert_equal '{"hello":"world"}', @response.body
end
end
end
end