Skip to content

Commit

Permalink
Temporarily commenting out deprecation warning until fixed. Adding te…
Browse files Browse the repository at this point in the history
…sts for `currentRouteName`. Removing `urlFor` until query params perf can be determined
  • Loading branch information
scalvert committed Jan 10, 2017
1 parent b4b9001 commit eb763a9
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 25 deletions.
20 changes: 0 additions & 20 deletions packages/ember-routing/lib/services/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,6 @@ const RouterService = Service.extend({
let router = get(this, 'router');

router.transitionTo(...arguments);
},

/**
Generates and returns a root relative URL string (inluding the application's `rootURL`. The route may
be either a single route or route path.
@method urlFor
@param {String} name the name of the route or a URL
@param {...Object} models the model(s) or identifier(s) to be used while
transitioning to the route.
@param {Object} [options] optional hash with a queryParams property
containing a mapping of query parameters
@return {Transition} the transition object associated with this
attempted transition
@public
*/
urlFor() {
let router = get(this, 'router');

return router.generate(...arguments);
}
});

Expand Down
10 changes: 5 additions & 5 deletions packages/ember-routing/lib/services/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export default Service.extend({
this._super(...arguments);

if (isEnabled('ember-routing-router-service')) {
deprecate(
'The private `-routing` service has been deprecated and will be removed.',
false,
{ id: 'ember-routing.-routing-service', until: '2.8.0' }
);
// deprecate(
// 'The private `-routing` service has been deprecated and will be removed.',
// false,
// { id: 'ember-routing.-routing-service', until: '2.8.0' }
// );
}
},

Expand Down
120 changes: 120 additions & 0 deletions packages/ember/tests/routing/router_service_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import Logger from 'ember-console';
import { Controller } from 'ember-runtime';
import { Route } from 'ember-routing';
import {
run,
get
} from 'ember-metal';
import { jQuery } from 'ember-views';
import inject from 'ember-runtime/inject';
import { ApplicationTestCase, moduleFor } from 'internal-test-helpers';


var Router, App, router, registry, container, originalLoggerError;

moduleFor('Router Serivce - main', class extends ApplicationTestCase {
['@test currentRouteName is correctly set for top level route'](assert) {
assert.expect(1);

let routerService;

this.router.map(function() {
this.route('parent', { path: '/' });
});

this.registerRoute('parent', Route.extend({
router: inject.service(),
init() {
routerService = get(this, 'router');
}
}));

return this.visit('/').then(() => {
assert.equal(routerService.get('currentRouteName'), 'parent');
});
}

['@test currentRouteName is correctly set for child route'](assert) {
assert.expect(1);

let routerService;

this.router.map(function() {
this.route('parent', { path: '/' }, function() {
this.route('child');
});
});

this.registerRoute('parent.child', Route.extend({
router: inject.service(),
init() {
routerService = get(this, 'router');
}
}));

return this.visit('/child').then(() => {
assert.equal(routerService.get('currentRouteName'), 'parent.child');
});
}

['@test currentRouteName is correctly set after transition'](assert) {
assert.expect(1);

let routerService;

this.router.map(function() {
this.route('parent', { path: '/' }, function() {
this.route('child');
this.route('sibling');
});
});

this.registerRoute('parent.child', Route.extend({
router: inject.service(),
init() {
routerService = get(this, 'router');
},

afterModel() {
this.transitionTo('parent.sibling');
}
}));

return this.visit('/child').then(() => {
assert.equal(routerService.get('currentRouteName'), 'parent.sibling');
});
}

['@test currentRouteName is correctly set on each transition'](assert) {
assert.expect(3);

let routerService;

this.router.map(function() {
this.route('parent', { path: '/' }, function() {
this.route('child');
this.route('sister');
this.route('brother')
});
});

this.registerRoute('parent.child', Route.extend({
router: inject.service(),
init() {
routerService = get(this, 'router');
}
}));

return this.visit('/child').then(() => {
assert.equal(routerService.get('currentRouteName'), 'parent.child');

return this.visit('/sister').then(() => {
assert.equal(routerService.get('currentRouteName'), 'parent.sister');

return this.visit('/brother').then(() => {
assert.equal(routerService.get('currentRouteName'), 'parent.brother');
});
});
});
}
});

0 comments on commit eb763a9

Please sign in to comment.