Permalink
Browse files

findOne and findAll in can/model don't work with can/construct/super.…

… The context (thisArg) is set incorrectly
  • Loading branch information...
cohuman committed Apr 4, 2012
1 parent f37c43f commit c93ae5478eea7fdb88fa6fc03211d81c8d4ca3bd
Showing with 26 additions and 3 deletions.
  1. +24 −1 construct/super/super_test.js
  2. +2 −2 model/model.js
@@ -41,7 +41,30 @@ test("static super", function(){
equal(Second.raise(2), 4)
-})
+});
+
+test("findAll super", function(){
+
+ var Parent = can.Model({
+ findAll: function(){
+ equal(this.shortName, 'child');
+ return new can.Deferred();
+ },
+ shortName : 'parent'
+ },{});
+
+ var Child = Parent({
+ findAll: function(){
+ return this._super();
+ },
+ shortName : 'child'
+ },{});
+
+ stop();
+ expect(1);
+ Child.findAll({});
+ start();
+});
/* Not sure I want to fix this yet.
test("Super in derived when parent doesn't have init", function(){
View
@@ -498,8 +498,8 @@ steal('can/observe',function(){
// Increment requests.
self._reqs++;
// Make the request.
- return pipe( old.call(self,params),
- self,
+ return pipe( old.call(this,params),
+ this,
method ).then(success,error).then(clean, clean);
}

0 comments on commit c93ae54

Please sign in to comment.