Skip to content

Commit

Permalink
Remove this.resource from RouterDSL
Browse files Browse the repository at this point in the history
  • Loading branch information
locks committed Jan 1, 2018
1 parent 2569225 commit 7f97511
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 45 deletions.
1 change: 0 additions & 1 deletion packages/ember-routing/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
13 changes: 1 addition & 12 deletions packages/ember-routing/lib/system/dsl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assign } from 'ember-utils';
import { assert, deprecate } from 'ember-debug';
import { assert } from 'ember-debug';

let uuid = 0;

Expand Down Expand Up @@ -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;

Expand Down
33 changes: 1 addition & 32 deletions packages/ember-routing/tests/system/dsl_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand All @@ -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) {
Expand Down

0 comments on commit 7f97511

Please sign in to comment.