Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moduleFor controller with needs fails on second call with undefined #16

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ Contributing

```sh
$ npm install
$ bower install
$ broccoli serve
# new tab
$ karma start
Expand Down
1 change: 1 addition & 0 deletions lib/module-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.$('<div id="ember-testing"/>').appendTo(document.body);
buildContextVariables(context);
Expand Down
28 changes: 27 additions & 1 deletion test/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down Expand Up @@ -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']
Expand Down