Permalink
Browse files

RejectWith fix for static model methods. Thanks @roelmonnens.

  • Loading branch information...
Ralph Holzmann
Ralph Holzmann committed May 18, 2012
1 parent 22cbe28 commit ff17833b52162348413ebdc47baaa389a90464f9
Showing with 53 additions and 7 deletions.
  1. +4 −3 control/route/route_test.js
  2. +1 −1 model/model.js
  3. +44 −0 model/model_test.js
  4. +1 −1 test/can_dojo.html
  5. +2 −1 test/setup.js
  6. +1 −1 test/test.html
@@ -30,21 +30,22 @@ test("routes changed", function () {
window.location.hash = '!foos';
can.trigger(window, 'hashchange');
});
test("route pointers", function(){
expect(1);
var tester = can.Control({
"foo/:bar route" : "meth",
"lol/:wat route" : "meth",
meth : function(){
ok(true, "method pointer called")
}
});
new tester(document.body);
window.location.hash = '!foo/bar';
window.location.hash = '!lol/wat';
can.trigger(window, 'hashchange');
})
})();
})();
View
@@ -15,7 +15,7 @@ steal('can/observe', function() {
arguments[0] = model[func](arguments[0])
d.resolve.apply(d, arguments)
},function(){
d.resolveWith.apply(this,arguments)
d.rejectWith.apply(this,arguments)
})
return d;
},
View
@@ -47,6 +47,50 @@ test("findAll deferred", function(){
})
});
asyncTest("findAll deferred reject", function() {
// This test is automatically paused
function rejectDeferred(df) {
setTimeout(function() { df.reject(); }, 100);
}
function resolveDeferred(df) {
setTimeout(function() { df.resolve(); }, 100);
}
can.Model("Person", {
findAll : function(params, success, error) {
var df = can.Deferred();
if(params.resolve) {
resolveDeferred(df);
} else {
rejectDeferred(df);
}
return df;
}
},{});
var people_reject = Person.findAll({ resolve : false});
var people_resolve = Person.findAll({ resolve : true});
setTimeout(function() {
people_reject.done(function() {
ok(false, "This deferred should be rejected");
});
people_reject.fail(function() {
ok(true, "The deferred is rejected");
});
people_resolve.done(function() {
ok(true, "This deferred is resolved");
});
people_resolve.fail(function() {
ok(false, "The deferred should be resolved");
});
// continue the test
start();
}, 200);
});
test("findOne deferred", function(){
if(window.jQuery){
can.Model("Person",{
View
@@ -18,4 +18,4 @@ <h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-test-area"></div>
</body>
</html>
</html>
View
@@ -5,6 +5,7 @@ steal('can/util/mvc.js')
var oldmodule = window.module,
library = 'jQuery';
// Set the test timeout to five minutes
QUnit.config.hidepassed = true;
QUnit.config.testTimeout = 300000;
if (window.STEALDOJO){
@@ -19,4 +20,4 @@ steal('can/util/mvc.js')
window.module = function(name, testEnvironment) {
oldmodule(library + '/' + name, testEnvironment);
}
})
})
View
@@ -13,7 +13,7 @@
}
iframe {
float: left;
width: 33.333%;
width: 32%;
height: 50%;
border-color: #eee;
border-style: dashed;

0 comments on commit ff17833

Please sign in to comment.