Skip to content

Commit

Permalink
[BUGFIX beta] Update verifyNeedsDependencies to throw instead of as…
Browse files Browse the repository at this point in the history
…sert.

A missing `needs` dependency should raise an error in production builds, not just
in dev builds.
  • Loading branch information
lukemelia committed Jan 2, 2014
1 parent 92b4648 commit c22755d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/ember-application/lib/ext/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ function verifyNeedsDependencies(controller, container, needs) {
missing.push(dependency);
}
}
Ember.assert(Ember.inspect(controller) + " needs [ " + missing.join(', ') + " ] but " + (missing.length > 1 ? 'they' : 'it') + " could not be found", !missing.length);
if (missing.length) {
throw new Ember.Error(Ember.inspect(controller) + " needs [ " + missing.join(', ') + " ] but " + (missing.length > 1 ? 'they' : 'it') + " could not be found");
}
}

var defaultControllersComputedProperty = Ember.computed(function() {
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-application/tests/system/controller_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ test("If a controller specifies an unavailable dependency, it raises", function(
needs: ['comments']
}));

expectAssertion(function() {
throws(function() {
container.lookup('controller:post');
}, /controller:comments/);

container.register('controller:blog', Ember.Controller.extend({
needs: ['posts', 'comments']
}));

expectAssertion(function() {
throws(function() {
container.lookup('controller:blog');
}, /controller:posts, controller:comments/);
});
Expand Down

0 comments on commit c22755d

Please sign in to comment.