[Pkg-javascript-commits] [backbone] 29/37: Fixes #917 -- reverts validate() behavior to never run on silent sets.
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 17:02:48 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.9.1
in repository backbone.
commit aafbcb05e5f8fcda3c4952cd9228e8947902af13
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date: Thu Feb 2 15:40:06 2012 -0500
Fixes #917 -- reverts validate() behavior to never run on silent sets.
---
backbone.js | 2 +-
test/collection.js | 11 ++++-------
test/model.js | 4 ++--
3 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/backbone.js b/backbone.js
index e889656..b91bdc6 100644
--- a/backbone.js
+++ b/backbone.js
@@ -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];
diff --git a/test/collection.js b/test/collection.js
index 9975947..1705f57 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -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}]); });
});
diff --git a/test/model.js b/test/model.js
index 346f2f0..1e951b5 100644
--- a/test/model.js
+++ b/test/model.js
@@ -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);
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list