#1412 - Trigger "sync" event for fetch also

This commit is contained in:
Casey Foster
2012-06-15 07:33:38 -07:00
parent 0b15e163ac
commit f24ca5a0ed
4 changed files with 36 additions and 2 deletions

View File

@@ -634,4 +634,17 @@ $(document).ready(function() {
col.fetch(opts);
col.create(m, opts);
});
test('#1412 - Trigger "sync" event for fetch also', 1, function() {
var collection = new Backbone.Collection;
collection.sync = function(method, model, options) {
options.success();
};
var syncTriggered = false;
collection.on('sync', function() {
syncTriggered = true;
});
collection.fetch();
ok(syncTriggered);
});
});

View File

@@ -831,4 +831,16 @@ $(document).ready(function() {
model.destroy(opts);
});
test('#1412 - Trigger "sync" event for fetch also', 1, function() {
var model = new Backbone.Model;
model.sync = function(method, model, options) {
options.success();
};
var syncTriggered = false;
model.on('sync', function() {
syncTriggered = true;
});
model.fetch();
ok(syncTriggered);
});
});