Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed deep chaining issue with pluggable classes

  • Loading branch information...
commit 127a96808d0121a0de7efac78b18ab01d54b3b00 1 parent 48ae155
@mikefrey mikefrey authored
Showing with 31 additions and 3 deletions.
  1. +1 −1  controller/index.js
  2. +1 −2  plugin.js
  3. +29 −0 test/plugins.js
View
2  controller/index.js
@@ -206,4 +206,4 @@ _.extend(Controller.prototype, EventEmitter.prototype, {
})
Controller.extend = extendable
-// Plugin.makePluggable(Controller)
+Plugin.makePluggable(Controller)
View
3  plugin.js
@@ -62,9 +62,8 @@ function makePluggable(Class, plugins) {
}
})
- var classExtend = Class.extend
Class.extend = function(inst, cls) {
- var SubClass = classExtend.call(Class, inst, cls)
+ var SubClass = extendable.call(Class, inst, cls)
makePluggable(SubClass, plugins)
return SubClass
}
View
29 test/plugins.js
@@ -179,4 +179,33 @@ describe('Plugin', function() {
})
+
+ describe('deep extending', function() {
+ var inst, Zero, One, Two, Three
+
+ it('should correctly walk the prototype chain without plugins', function(done) {
+ Zero = createTestClass()
+ One = Zero.extend({ one: sinon.spy() })
+ Two = One.extend({ two: sinon.spy() })
+ Three = Two.extend({ three: sinon.spy() })
+
+ inst = new Three()
+ assert(!!inst.two)
+ done()
+ })
+
+ it('should not block walking the prototype chain', function(done) {
+ Zero = createTestClass()
+ Plugin.makePluggable(Zero)
+ One = Zero.extend({ one: sinon.spy() })
+ Two = One.extend({ two: sinon.spy() })
+ Three = Two.extend({ three: sinon.spy() })
+
+ inst = new Three()
+ assert(!!inst.two)
+ done()
+ })
+
+ })
+
})
Please sign in to comment.
Something went wrong with that request. Please try again.