emberjs/data — pull request #682 by bobbus (2013-02-01 17:31:53+00:00)
Title: Improve errors handling for embedding records

This is a first try to handle errors with embedded records. When talking about embedded records here, I will assume it's an `embedded: always` association.

As of now, when an *Error 422* is returned from a commit, the record commited become *invalid*. We expect that the 422 returns a json object with an `errors` key, and from the doc :

> The errors object must have keys that correspond to the
> attribute names. Once each of the specified attributes have
> changed, the record will automatically move out of the
> invalid state and be ready to commit again.

This is great but it's not working for embedded records : they are not flagged as *invalid*, they stay *inFlight* and never get out of this state. It avoid us to commit the record again.

What I did is ensure that all embedded records will go to the *invalid* state and will become *uncommitted* when needed (see below).

In case of embedded record modification, the JSON errors returned is ignored and it will become *uncommited* for any modification, the parent will be send to the *uncommitted* state as well as all of his embedded records.

This could definitely be improved but it requires some works to manage the serialization of errors for embedded object. For now at least, this PR make it possible to use the 422 behavior of the `RESTAdapter` with embedded object.

If this one get a chance of merge, I will be happy to improve the code / architecture in any way and of course will write the needed tests.