Permalink
Browse files

store original Backbone.sync in Backbone.ajaxSync for model overrides

  • Loading branch information...
1 parent f7c1681 commit 17e92ea3c9cf21d3efbdc353e5ed9abcd67bb7f1 @wnadeau committed Mar 1, 2012
Showing with 13 additions and 1 deletion.
  1. +1 −0 backbone-indexeddb.js
  2. +7 −1 tests/backbone-indexeddbTests.js
  3. +5 −0 tests/test.html
@@ -520,6 +520,7 @@
};
if(typeof exports == 'undefined'){
+ Backbone.ajaxSync = Backbone.sync;
Backbone.sync = sync;
}
else {
@@ -710,4 +710,10 @@ backboneIndexedDBTest.prototype.testReadCollection = function (queue) {
);
-};
+};
+backboneIndexedDBTest.prototype.testRememberAjaxSync = function(queue){
@wnadeau
wnadeau Mar 1, 2012 Owner

oh yeah I'm totally unfamiliar with this testing process. I'm probably missing something obvious, but I wasn't sure how to even run it. It may not matter. The browser test is fine though.

+ queue.call("Backbone.ajaxSync should be remembered for models that need async actions",function(callbacks){
+ assertEquals("Should be the original Backbone.sync function",typeof Backbone.ajaxSync, "function")
+ }
+ );
+}
View
@@ -644,6 +644,11 @@
// this is a bit hokey, but will do the trick.
if (collection.length === 5) nextTest();
});
+ }],
+ ["support for model specific sync override", function(){
+ start();
+ equals(typeof Backbone.ajaxSync,'function', "should not be the original Backbone.sync function" );
+ nextTest();
}]
];

1 comment on commit 17e92ea

@jobetudiant

So, let me make sure I get this right: you just rebind the existing Backbone.sync to Backbone.ajaxSync so that it can be used somewhere else?
This seems fair :) LMK if I'm missing something. Otherwise I'll merge!

Please sign in to comment.