Skip to content

Commit c93ae54

Browse files
author
Cohuman Dev
committed
findOne and findAll in can/model don't work with can/construct/super. The context (thisArg) is set incorrectly
1 parent f37c43f commit c93ae54

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

construct/super/super_test.js

+24-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,30 @@ test("static super", function(){
4141

4242
equal(Second.raise(2), 4)
4343

44-
})
44+
});
45+
46+
test("findAll super", function(){
47+
48+
var Parent = can.Model({
49+
findAll: function(){
50+
equal(this.shortName, 'child');
51+
return new can.Deferred();
52+
},
53+
shortName : 'parent'
54+
},{});
55+
56+
var Child = Parent({
57+
findAll: function(){
58+
return this._super();
59+
},
60+
shortName : 'child'
61+
},{});
62+
63+
stop();
64+
expect(1);
65+
Child.findAll({});
66+
start();
67+
});
4568

4669
/* Not sure I want to fix this yet.
4770
test("Super in derived when parent doesn't have init", function(){

model/model.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ steal('can/observe',function(){
498498
// Increment requests.
499499
self._reqs++;
500500
// Make the request.
501-
return pipe( old.call(self,params),
502-
self,
501+
return pipe( old.call(this,params),
502+
this,
503503
method ).then(success,error).then(clean, clean);
504504
}
505505

0 commit comments

Comments
 (0)