From 7f97511a034dccf140a39127bd6a93bf8ceb0a7b Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Wed, 29 Nov 2017 20:15:02 +0000 Subject: [PATCH] Remove this.resource from RouterDSL --- packages/ember-routing/lib/index.d.ts | 1 - packages/ember-routing/lib/system/dsl.js | 13 +------- .../ember-routing/tests/system/dsl_test.js | 33 +------------------ 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/packages/ember-routing/lib/index.d.ts b/packages/ember-routing/lib/index.d.ts index 80e4b2fe666..8b24c45b0fd 100644 --- a/packages/ember-routing/lib/index.d.ts +++ b/packages/ember-routing/lib/index.d.ts @@ -71,7 +71,6 @@ export class RouterDSL { constructor(name: string, options: any); route(name: string, options: any, callback: ()=>any): void; push(url: string, name: string, callback: ()=>any, serialize: ()=>any): void; - resource(name: string, options: any, callback: ()=>any): void; genearte(): (match: any) => void; mount(_name: string, options: any): void; } diff --git a/packages/ember-routing/lib/system/dsl.js b/packages/ember-routing/lib/system/dsl.js index d4939c68fb2..d07d7e44cd1 100644 --- a/packages/ember-routing/lib/system/dsl.js +++ b/packages/ember-routing/lib/system/dsl.js @@ -1,5 +1,5 @@ import { assign } from 'ember-utils'; -import { assert, deprecate } from 'ember-debug'; +import { assert } from 'ember-debug'; let uuid = 0; @@ -66,17 +66,6 @@ class DSL { this.matches.push(url, name, callback); } - resource(name, options = {}, callback) { - if (arguments.length === 2 && typeof options === 'function') { - callback = options; - options = {}; - } - - options.resetNamespace = true; - deprecate('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.', false, { id: 'ember-routing.router-resource', until: '3.0.0' }); - this.route(name, options, callback); - } - generate() { let dslMatches = this.matches; diff --git a/packages/ember-routing/tests/system/dsl_test.js b/packages/ember-routing/tests/system/dsl_test.js index 777469c8d47..84e6ff783da 100644 --- a/packages/ember-routing/tests/system/dsl_test.js +++ b/packages/ember-routing/tests/system/dsl_test.js @@ -15,10 +15,9 @@ moduleFor('Ember Router DSL', class extends AbstractTestCase { } ['@test should fail when using a reserved route name'](assert) { - expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.'); let reservedNames = ['array', 'basic', 'object', 'application']; - assert.expect((reservedNames.length * 2) + 1); + assert.expect(reservedNames.length); reservedNames.forEach(reservedName => { expectAssertion(() => { @@ -31,37 +30,7 @@ moduleFor('Ember Router DSL', class extends AbstractTestCase { let router = Router.create(); router._initRouterJs(); }, '\'' + reservedName + '\' cannot be used as a route name.'); - - expectAssertion(() => { - Router = EmberRouter.extend(); - - Router.map(function() { - this.resource(reservedName); - }); - - let router = Router.create(); - router._initRouterJs(); - }, `'${reservedName}' cannot be used as a route name.`); - }); - } - - ['@test should reset namespace if nested with resource'](assert) { - expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.'); - - Router = Router.map(function() { - this.resource('bleep', function() { - this.resource('bloop', function() { - this.resource('blork'); - }); - }); }); - - let router = Router.create(); - router._initRouterJs(); - - assert.ok(router._routerMicrolib.recognizer.names['bleep'], 'nested resources do not contain parent name'); - assert.ok(router._routerMicrolib.recognizer.names['bloop'], 'nested resources do not contain parent name'); - assert.ok(router._routerMicrolib.recognizer.names['blork'], 'nested resources do not contain parent name'); } ['@test should retain resource namespace if nested with routes'](assert) {