Skip to content

Commit

Permalink
Merge pull request #10528 from rwjblue/ensure-router-can-be-specified
Browse files Browse the repository at this point in the history
[BUGFIX beta] Ensure custom Router can be passed to Ember.Application.
  • Loading branch information
stefanpenner committed Feb 25, 2015
2 parents 0eac6b4 + 68e21a4 commit 25e679b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/ember-application/lib/system/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,11 @@ var Application = Namespace.extend(DeferredMixin, {
// This is to ensure that someone reopening `App.Router` does not
// tamper with the default `Ember.Router`.
// 2.0TODO: Can we move this into a globals-mode-only library?
this.Router = Router.extend();
this.Router = (this.Router || Router).extend();
this.waitForDOMReady(this.buildDefaultInstance());
}
} else {
this.Router = Router.extend();
this.Router = (this.Router || Router).extend();
this.waitForDOMReady(this.buildDefaultInstance());
}
},
Expand Down
12 changes: 12 additions & 0 deletions packages/ember-application/tests/system/application_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,18 @@ QUnit.test("can resolve custom router", function() {
ok(app.__container__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router');
});

QUnit.test("can specify custom router", function() {
var CustomRouter = Router.extend();

app = run(function() {
return Application.create({
Router: CustomRouter
});
});

ok(app.__container__.lookup('router:main') instanceof CustomRouter, 'application resolved the correct router');
});

QUnit.test("throws helpful error if `app.then` is used", function() {
run(function() {
app = Application.create({
Expand Down

0 comments on commit 25e679b

Please sign in to comment.