Permalink
Browse files

clearing out rest of mementos

  • Loading branch information...
jondot committed Aug 30, 2011
1 parent 4537b9f commit 527788f854c53c3ad484999c240a2695b50304db
Showing with 21 additions and 0 deletions.
  1. +4 −0 backbone.memento.js
  2. +17 −0 spec/javascripts/memento.spec.js
View
@@ -68,7 +68,11 @@ Backbone.Memento = (function(model){
return null;
}
+
+
restoreState(0);
+ // restoreState deleted item 0, but really we should be starting from scratch.
+ attributeStack = new Array();
}
}
});
@@ -85,6 +85,23 @@ describe("memento", function(){
});
+ it("should lose all other save points", function(){
+ var changed = false;
+ this.model.set({foo: "bar"});
+ this.model.store();
+ this.model.set({foo: "baz"});
+ this.model.store();
+ this.model.set({foo: "qux"});
+ this.model.store();
+
+ this.model.clear();
+ this.model.restore();
+
+ expect(this.model.get('foo')).toBe('bar'); //should not be qux
+ });
+
+
+
it("should do nothing given no store point", function(){
var changed = false;
this.model.set({foo: "bar"});

0 comments on commit 527788f

Please sign in to comment.