Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove this.resource from RouterDSL #15883

Merged
merged 1 commit into from
Jan 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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