Permalink
Browse files

Immediately notify records of status changes when destroyed

Signed-off-by: Charles Jolley <charles@sproutit.com>
  • Loading branch information...
1 parent 8c54dc5 commit 1856229bb77fbb90389a2d41006ab39b0bc0240b @wagenet wagenet committed with Charles Jolley Nov 17, 2009
Showing with 12 additions and 0 deletions.
  1. +1 −0 frameworks/datastore/models/record.js
  2. +11 −0 frameworks/datastore/tests/models/record/destroy.js
@@ -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 ;
},
@@ -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.