ismasan/oat — pull request #49 by dpdawson (2014-10-03 23:43:33+00:00)
Title: Stop entities/entity from duplicating entries in linked hash.

As specified at http://jsonapi.org/format:

> If a primary document is linked to another primary or linked document, it should not be duplicated within the "linked" object.

The current json api adapter will duplicate documents in the "linked" object if multiple other documents link to it.

For example, the current implementation would do this:

```javascript
{
:purchases => [
{
:id => 1,
:links =>
{
:bids => [2],
:game => 3
}
}
],
:linked => {
:bids => [
{:id => 2},
{:id => 2}
],
:games => [
{
:id => 3,
:links => {
:bids => [2]
}
}
]
}
}
```

Instead of this:

```javascript
{
:purchases => [
{
:id => 1,
:links =>
{
:bids => [2],
:game => 3
}
}
],
:linked => {
:bids => [
{:id => 2}
],
:games => [
{
:id => 3,
:links => {
:bids => [2]
}
}
]
}
}
```

Notice the incorrect double entry under [:linked][:bids].

This pull request fixes that.

I started to add some tests, but didn't have enough time to make the necessary changes to the fixtures to accommodate the tests. The fix is simple enough, though.