From ca57569e35b923e7b117a4bf38b6f0a3cde642ae Mon Sep 17 00:00:00 2001 From: Manuel Wiedenmann Date: Wed, 26 Mar 2014 13:46:54 +0100 Subject: [PATCH 1/2] moduleFor controller with needs fails on second call with undefined --- README.md | 1 + test/main.spec.js | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 861240eb..d2a08d3b 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ Contributing ```sh $ npm install +$ bower install $ broccoli serve # new tab $ karma start diff --git a/test/main.spec.js b/test/main.spec.js index ffa5a2ce..9757dcb3 100644 --- a/test/main.spec.js +++ b/test/main.spec.js @@ -12,7 +12,10 @@ var Comment = DS.Model.extend({ var registry = { 'component:x-foo': Ember.Component.extend(), 'route:foo': Ember.Route.extend(), - 'controller:bar': Ember.Controller.extend(), + 'controller:foos': Ember.ArrayController.extend(), + 'controller:bar': Ember.Controller.extend({ + needs: ['foos'] + }), 'model:post': Post, 'model:comment': Comment }; @@ -45,6 +48,29 @@ setResolver(Resolver.create()); //ok(controller instanceof registry['controller:bar']); //}); +moduleFor('controller:bar', 'moduleFor with bar controller', { + needs: ['controller:foos'] +}); + +test('exists', function() { + var bar = this.subject(); + + foos = bar.get('controllers.foos'); + + ok(bar); + ok(bar instanceof Ember.Controller); + ok(foos instanceof Ember.ArrayController); +}); + +test('exists again', function() { + var bar = this.subject(); + + foos = bar.get('controllers.foos'); + + ok(bar); + ok(bar instanceof Ember.Controller); + ok(foos instanceof Ember.ArrayController); +}); moduleForModel('post', 'moduleForModel with post', { needs: ['model:comment'] From 07c720977e1497b003cd345151768c9d0059deab Mon Sep 17 00:00:00 2001 From: Manuel Wiedenmann Date: Wed, 26 Mar 2014 14:42:21 +0100 Subject: [PATCH 2/2] creates a new container in setup --- lib/module-for.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/module-for.js b/lib/module-for.js index cc322d88..38649d5e 100644 --- a/lib/module-for.js +++ b/lib/module-for.js @@ -39,6 +39,7 @@ export default function moduleFor(fullName, description, callbacks, delegate) { var dispatcher = Ember.EventDispatcher.create(); var _callbacks = { setup: function(){ + container = isolatedContainer(needs); dispatcher.setup(); Ember.$('
').appendTo(document.body); buildContextVariables(context);