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 Nov 29, 2017
1 parent b19c4f7 commit 430621f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 43 deletions.
11 changes: 0 additions & 11 deletions packages/ember-routing/lib/system/dsl.js
Original file line number Diff line number Diff line change
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 @@ -18,10 +18,9 @@ QUnit.module('Ember Router DSL', {
});

QUnit.test('should fail when using a reserved route name', function() {
expectDeprecation('this.resource() is deprecated. Use this.route(\'name\', { resetNamespace: true }, function () {}) instead.');
let reservedNames = ['array', 'basic', 'object', 'application'];

expect((reservedNames.length * 2) + 1);
expect(reservedNames.length + 1);

reservedNames.forEach(reservedName => {
expectAssertion(() => {
Expand All @@ -34,37 +33,7 @@ QUnit.test('should fail when using a reserved route name', function() {
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.`);
});
});

QUnit.test('should reset namespace if nested with resource', function() {
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();

ok(router._routerMicrolib.recognizer.names['bleep'], 'nested resources do not contain parent name');
ok(router._routerMicrolib.recognizer.names['bloop'], 'nested resources do not contain parent name');
ok(router._routerMicrolib.recognizer.names['blork'], 'nested resources do not contain parent name');
});

QUnit.test('should retain resource namespace if nested with routes', function() {
Expand Down

0 comments on commit 430621f

Please sign in to comment.