zendesk/ember-resource — pull request #95 by dadah89 (2014-08-07 17:45:17+00:00)
Title: HasOneNestedSchemaItem setValue: delegate to id schema item when setting association to another instance

When the parent resource sets the nested resource with a new instance of
the related type, and a subsequent fetch happens, changing the associated
nested resource id, some data from the old instance carries over to the
new instance.

Considering two groups:

```js
{
id: 6,
name: "Development",
agents: [ { id: 2, name: "Development Agent" } ]
}
```

```js
{
id: 7,
name: "Support",
agents: [ { id: 3, name: "Support Agent" } ]
}
```

If a parent object sets its group to the Development group object, parent.data.group will look like:

```js
{
group: {
id: 6,
name: "Development",
agents: [ { id: 2, name: "Development Agent" } ]
}
}
```

If the parent object is fetched, and the response payload contains the Support group, but with not all attributes (id and name),

```js
{
group: {
id: 7,
name: "Support"
}
}
```

then parent.data.group will look like:

```js
{
group: {
id: 7,
name: "Support",
agents: [ { id: 2, name: "Development Agent" } ]
}
}
```

As the parent.data changes, properties that declares it as dependencies will fire, including parent.get('group'). In `getValue`, it will extract the id from the hash (7), fetch the group object with id 7 from the identity map, and update it with the hash content ("Support" name, which will be the same as before, and agents, which will be replaced with Development agents...).

/cc @jish @shajith @jamesarosen @kruppel