From fcc7441aeaefb09b75f72eb55513ca5036672473 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 25 Feb 2015 09:51:20 -0500 Subject: [PATCH] [BUGFIX beta] Do not allow manually specifying `application` resource. --- packages/ember-routing/lib/system/dsl.js | 9 ++++++++- packages/ember-routing/lib/system/router.js | 2 +- packages/ember-routing/tests/system/dsl_test.js | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/ember-routing/lib/system/dsl.js b/packages/ember-routing/lib/system/dsl.js index daed7c9d995..bde1e3f0027 100644 --- a/packages/ember-routing/lib/system/dsl.js +++ b/packages/ember-routing/lib/system/dsl.js @@ -24,7 +24,14 @@ DSL.prototype = { } var type = options.resetNamespace === true ? 'resource' : 'route'; - Ember.assert("'" + name + "' cannot be used as a " + type + " name.", name !== 'array' && name !== 'basic' && name !== 'object'); + Ember.assert( + "'" + name + "' cannot be used as a " + type + " name.", + (function() { + if (options.overrideNameAssertion === true) { return true; } + + return ['array', 'basic', 'object', 'application'].indexOf(name) === -1; + })() + ); if (Ember.FEATURES.isEnabled("ember-routing-named-substates")) { if (this.enableLoadingSubstates) { diff --git a/packages/ember-routing/lib/system/router.js b/packages/ember-routing/lib/system/router.js index 4660b150d16..5f9dd5266d5 100644 --- a/packages/ember-routing/lib/system/router.js +++ b/packages/ember-routing/lib/system/router.js @@ -81,7 +81,7 @@ var EmberRouter = EmberObject.extend(Evented, { }); function generateDSL() { - this.resource('application', { path: "/" }, function() { + this.resource('application', { path: "/", overrideNameAssertion: true }, function() { for (var i=0; i < dslCallbacks.length; i++) { dslCallbacks[i].call(this); } diff --git a/packages/ember-routing/tests/system/dsl_test.js b/packages/ember-routing/tests/system/dsl_test.js index 1e84eae77d2..15c709b8838 100644 --- a/packages/ember-routing/tests/system/dsl_test.js +++ b/packages/ember-routing/tests/system/dsl_test.js @@ -13,7 +13,7 @@ QUnit.module("Ember Router DSL", { }); QUnit.test("should fail when using a reserved route name", function() { - var reservedNames = ['array', 'basic', 'object']; + var reservedNames = ['array', 'basic', 'object', 'application']; expect(reservedNames.length * 2);