mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Make render json work when not using AMS
This commit is contained in:
parent
7405baafd7
commit
8462a73f3a
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user