Skip to content

Commit

Permalink
Immediately notify records of status changes when destroyed
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Jolley <charles@sproutit.com>
  • Loading branch information
wagenet authored and Charles Jolley committed Nov 17, 2009
1 parent 8c54dc5 commit 1856229
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions frameworks/datastore/models/record.js
Expand Up @@ -210,6 +210,7 @@ SC.Record = SC.Object.extend(
*/
destroy: function() {
this.get('store').destroyRecord(null, null, this.get('storeKey'));
this.propertyDidChange('status');
return this ;
},

Expand Down
11 changes: 11 additions & 0 deletions frameworks/datastore/tests/models/record/destroy.js
Expand Up @@ -79,3 +79,14 @@ test("should return receiver", function() {
equals(MyApp.foo.destroy(), MyApp.foo, 'should return receiver');
});

test("destroy should update status cache", function() {
var st = MyApp.foo.get('status');
ok(st !== SC.Record.DESTROYED_CLEAN, 'precond - foo should not be destroyed');

SC.RunLoop.begin();
MyApp.foo.destroy();
equals(MyApp.foo.get('status'), SC.Record.DESTROYED_CLEAN, 'status should be DESTROYED_CLEAN immediately when destroyed directly by record');
SC.RunLoop.end();
});


0 comments on commit 1856229

Please sign in to comment.