mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-22 13:28:22 -05:00
Fixes #917 -- reverts validate() behavior to never run on silent sets.
This commit is contained in:
@@ -225,7 +225,7 @@
|
||||
if (options.unset) for (attr in attrs) attrs[attr] = void 0;
|
||||
|
||||
// Run validation.
|
||||
if (!this._validate(attrs, options)) return false;
|
||||
if (!options.silent && !this._validate(attrs, options)) return false;
|
||||
|
||||
// Check for changes of `id`.
|
||||
if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
|
||||
|
||||
@@ -373,9 +373,7 @@ $(document).ready(function() {
|
||||
model: ValidatingModel
|
||||
});
|
||||
var col = new ValidatingCollection();
|
||||
raises(function(){
|
||||
equal(col.create({"foo":"bar"}),false);
|
||||
});
|
||||
equal(col.create({"foo":"bar"}), false);
|
||||
});
|
||||
|
||||
test("Collection: a failing create runs the error callback", function() {
|
||||
@@ -390,9 +388,8 @@ $(document).ready(function() {
|
||||
var flag = false;
|
||||
var callback = function(model, error) { flag = true; };
|
||||
var col = new ValidatingCollection();
|
||||
raises(function(){
|
||||
col.create({"foo":"bar"}, { error: callback });
|
||||
});
|
||||
col.create({"foo":"bar"}, { error: callback });
|
||||
equal(flag, true);
|
||||
});
|
||||
|
||||
test("collection: initialize", function() {
|
||||
@@ -539,7 +536,7 @@ $(document).ready(function() {
|
||||
test("Collection: multiple copies of the same model", function() {
|
||||
var col = new Backbone.Collection();
|
||||
var model = new Backbone.Model();
|
||||
raises(function() { col.add([model, model]) });
|
||||
raises(function() { col.add([model, model]); });
|
||||
raises(function() { col.add([{id: 1}, {id: 1}]); });
|
||||
});
|
||||
|
||||
|
||||
@@ -392,9 +392,9 @@ $(document).ready(function() {
|
||||
equal(model.get('a'), 100);
|
||||
equal(lastError, undefined);
|
||||
result = model.set({admin: true}, {silent: true});
|
||||
equal(model.get('admin'), true);
|
||||
result = model.set({a: 200, admin: false});
|
||||
equal(lastError, "Can't change admin status.");
|
||||
equal(model.get('admin'), void 0);
|
||||
result = model.set({a: 200, admin: true});
|
||||
equal(result, false);
|
||||
equal(model.get('a'), 100);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user