Fixes #1211 - retrieve the key from the reflection options when building associations

This commit is contained in:
Liam Bowen
2015-09-29 16:18:47 +00:00
committed by L. Preston Sego III
parent 1f08865a10
commit f8323fc9e5
3 changed files with 20 additions and 1 deletions

View File

@@ -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)