From 68e21a47a1807d94d67fd1f5d8ae678688b0721e Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 25 Feb 2015 00:47:48 -0500 Subject: [PATCH] [BUGFIX beta] Ensure custom Router can be passed to Ember.Application. --- packages/ember-application/lib/system/application.js | 4 ++-- .../tests/system/application_test.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/ember-application/lib/system/application.js b/packages/ember-application/lib/system/application.js index 8336131c868..1abdcb6bbaa 100644 --- a/packages/ember-application/lib/system/application.js +++ b/packages/ember-application/lib/system/application.js @@ -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()); } }, diff --git a/packages/ember-application/tests/system/application_test.js b/packages/ember-application/tests/system/application_test.js index 90639dbf80d..f8ba036533d 100644 --- a/packages/ember-application/tests/system/application_test.js +++ b/packages/ember-application/tests/system/application_test.js @@ -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({