mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Fixes #1211 - retrieve the key from the reflection options when building associations
This commit is contained in:
committed by
L. Preston Sego III
parent
1f08865a10
commit
f8323fc9e5
@@ -46,6 +46,11 @@ module ActionController
|
||||
render json: @post, include: [:author], adapter: :json_api
|
||||
end
|
||||
|
||||
def render_resource_with_include_of_custom_key_by_original
|
||||
setup_post
|
||||
render json: @post, include: [:reviews], adapter: :json_api, serializer: PostWithCustomKeysSerializer
|
||||
end
|
||||
|
||||
def render_resource_with_nested_include
|
||||
setup_post
|
||||
render json: @post, include: [comments: [:author]], adapter: :json_api
|
||||
@@ -137,6 +142,18 @@ module ActionController
|
||||
assert_equal expected_linked, response['included']
|
||||
end
|
||||
|
||||
def test_render_resource_with_include_of_custom_key_by_original
|
||||
get :render_resource_with_include_of_custom_key_by_original
|
||||
response = JSON.parse(@response.body)
|
||||
assert response.key? 'included'
|
||||
|
||||
relationships = response['data']['relationships']
|
||||
|
||||
assert_includes relationships, 'reviews'
|
||||
assert_includes relationships, 'writer'
|
||||
assert_includes relationships, 'site'
|
||||
end
|
||||
|
||||
def test_render_resource_with_nested_include
|
||||
get :render_resource_with_nested_include
|
||||
response = JSON.parse(@response.body)
|
||||
|
||||
Reference in New Issue
Block a user