mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-23 05:48:10 -05:00
@@ -1152,7 +1152,8 @@
|
||||
|
||||
// Wrap an optional error callback with a fallback error event.
|
||||
var wrapError = function(onError, model, options) {
|
||||
return function(resp) {
|
||||
return function(model, resp) {
|
||||
var resp = model === model ? resp : model;
|
||||
if (onError) {
|
||||
onError(model, resp, options);
|
||||
} else {
|
||||
|
||||
@@ -277,6 +277,22 @@ $(document).ready(function() {
|
||||
model.set({lastName: 'Hicks'});
|
||||
});
|
||||
|
||||
test("Model: validate after save", function() {
|
||||
var lastError, model = new Backbone.Model();
|
||||
model.validate = function(attrs) {
|
||||
if (attrs.admin) return "Can't change admin status.";
|
||||
};
|
||||
model.sync = function(method, model, options) {
|
||||
options.success.call(this, {admin: true});
|
||||
};
|
||||
model.save(null, {error: function(model, error) {
|
||||
console.log('erroring!');
|
||||
lastError = error;
|
||||
}});
|
||||
|
||||
equals(lastError, "Can't change admin status.");
|
||||
});
|
||||
|
||||
test("Model: save", function() {
|
||||
doc.save({title : "Henry V"});
|
||||
equals(lastRequest[0], 'update');
|
||||
|
||||
Reference in New Issue
Block a user