Skip to content

Commit

Permalink
Merge c536c56 into a543646
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanfoster committed Nov 18, 2017
2 parents a543646 + c536c56 commit e6b9060
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Controller {
*/
registry.inject(this, "service:store", "store");

if (this.modelNameLookup) {
try {
/**
* The model class that belongs to this controller. If none could be found
* this will be undefined.
Expand All @@ -106,6 +106,11 @@ class Controller {
* @type {Object}
*/
registry.inject(this, `model:${this.modelNameLookup}`, "internalModel");
} catch (err) {
registry.lookup("service:logger").debug({
error: err,
controller: this.name
}, "failed to load model");
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/controller_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ describe("Controller", function () {
expect(controller.internalModel.name).to.eql("User");
});

it("loads without a model", function () {
class SomeController extends Controller {}

expect(function () {
new SomeController(registry);
}).to.not.throw;
});

it("overrides model when provided", function () {
class UserController extends Controller {}

Expand Down

0 comments on commit e6b9060

Please sign in to comment.