kevin-brown/drf-json-api — pull request #20 by jwhitlock (2014-11-11 23:10:46+00:00)
Title: Fix bug w/ linked items in nested resources

In `JsonApiMixin.handle_nested_serializer`, if the nested resource
contained links, then extra items would be added to the links section,
due to reusing the variable `linked_ids` in the loop. This code changes
the loop variable to `converted_ids`.

The relevant section of the JSON API spec is:

http://jsonapi.org/format/#document-structure-compound-documents

It does not detail what should happen when an included resourse contains
links. It does say:

> The type of each relationship MAY be specified in a resource-level or
> top- level "links" object with the "type" key. This facilitates
> lookups of linked resource objects by the client.

The previous behaviour was certainly a bug. Tests are included to
demonstrate current behaviour, and can be amended when / if the JSON API
spec has more details about compound documents.