[Pkg-javascript-commits] [backbone] 121/211: Add a failing test for Collection.create not running callbacks

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.5.0
in repository backbone.

commit 0f118ecb6e7b9021de49fcceadd5144b4996b277
Author: Pablo A. Torres Navarrete <tn.pablo at gmail.com>
Date:   Thu Apr 21 12:07:11 2011 -0500

    Add a failing test for Collection.create not running callbacks
---
 test/collection.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/test/collection.js b/test/collection.js
index 865d823..1d679af 100644
--- a/test/collection.js
+++ b/test/collection.js
@@ -233,6 +233,22 @@ $(document).ready(function() {
     equals(col.create({"foo":"bar"}),false);
   });
 
+  test("Collection: a failing create runs the error callback", function() {
+    var ValidatingModel = Backbone.Model.extend({
+      validate: function(attrs) {
+        return "fail";
+      }
+    });
+    var ValidatingCollection = Backbone.Collection.extend({
+      model: ValidatingModel
+    });
+    var flag = false;
+    var callback = function(model, error) { flag = true; };
+    var col = new ValidatingCollection();
+    col.create({"foo":"bar"}, { error: callback });
+    equals(flag, true);
+  });
+
   test("collection: initialize", function() {
     var Collection = Backbone.Collection.extend({
       initialize: function() {

-- 
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