emberjs/data — pull request #1659 by bmac (2014-01-14 05:57:19+00:00)
Title: Setting a property to undefined on a new record should not transition th...

...e record to root.deleted.saved

This is a fix for https://github.com/emberjs/data/issues/1648

Setting a property to undefined on a newly created record with no other properties set will run the `propertyWasReset` event which in turn triggers the `rolledBack` event which will transition a record in the `root.loaded.created.uncommitted` state to the `root.deleted.saved` state.

This can happen if a programmer writes an action like the one below where `email` and `password` are bound to `{{input}}`s. If a user causes the `signup` to trigger before focusing the inputs then the `user` record will be transitioned to the `root.deleted.saved` state and will never be able to be persisted to the backend.

```js
App.SignupController = Ember.ObjectController.extend({
actions: {
signup: function() {
var newUser = this.store.createRecord('user', {
name: this.get('email'),
password: this.get('password'),
});
newUser.save();
}
}
});
```

The fix for this method defines a `propertyWasReset` event on the `root.loaded.created.uncommitted` state which acts as a noop.