mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
add support for root keys
remove debugging gem fix white space
This commit is contained in:
@@ -5,7 +5,13 @@ module ActionController
|
||||
class ImplicitSerializerTest < ActionController::TestCase
|
||||
class MyController < ActionController::Base
|
||||
def render_using_implicit_serializer
|
||||
render json: Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
render json: @profile
|
||||
end
|
||||
|
||||
def render_using_custom_root
|
||||
@profile = Profile.new({ name: 'Name 1', description: 'Description 1', comments: 'Comments 1' })
|
||||
render json: @profile, root: "custom_root"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,8 +24,13 @@ module ActionController
|
||||
assert_equal 'application/json', @response.content_type
|
||||
assert_equal '{"name":"Name 1","description":"Description 1"}', @response.body
|
||||
end
|
||||
|
||||
def test_render_using_custom_root
|
||||
get :render_using_custom_root
|
||||
|
||||
assert_equal 'application/json', @response.content_type
|
||||
assert_equal '{"custom_root":{"name":"Name 1","description":"Description 1"}}', @response.body
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user