Skip to content

Commit

Permalink
Remove old Router Service FF
Browse files Browse the repository at this point in the history
This removes the FF around all the router service features that were
go'd earlier this year. It also reuses the same flag to guard the new
features that we are adding.
  • Loading branch information
chadhietala committed Oct 3, 2018
1 parent d8ee552 commit 0f95c77
Show file tree
Hide file tree
Showing 10 changed files with 1,043 additions and 1,050 deletions.
7 changes: 2 additions & 5 deletions packages/@ember/application/lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import Engine from '@ember/engine';
import { privatize as P } from '@ember/-internals/container';
import { setupApplicationRegistry } from '@ember/-internals/glimmer';
import { RouterService } from '@ember/-internals/routing';
import { EMBER_ROUTING_ROUTER_SERVICE } from '@ember/canary-features';

let librariesRegistered = false;

Expand Down Expand Up @@ -1124,10 +1123,8 @@ function commonSetupRegistry(registry) {
},
});

if (EMBER_ROUTING_ROUTER_SERVICE) {
registry.register('service:router', RouterService);
registry.injection('service:router', '_router', 'router:main');
}
registry.register('service:router', RouterService);
registry.injection('service:router', '_router', 'router:main');
}

function registerLibraries() {
Expand Down
2 changes: 1 addition & 1 deletion packages/@ember/canary-features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const DEFAULT_FEATURES = {
EMBER_LIBRARIES_ISREGISTERED: null,
EMBER_IMPROVED_INSTRUMENTATION: null,
EMBER_GLIMMER_NAMED_ARGUMENTS: true,
EMBER_ROUTING_ROUTER_SERVICE: true,
EMBER_ROUTING_ROUTER_SERVICE: null,
EMBER_ENGINES_MOUNT_PARAMS: true,
EMBER_MODULE_UNIFICATION: null,
GLIMMER_CUSTOM_COMPONENT_MANAGER: true,
Expand Down
54 changes: 37 additions & 17 deletions packages/ember/tests/routing/decoupled_basic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getTextOf } from 'internal-test-helpers';
import { Component } from '@ember/-internals/glimmer';
import Engine from '@ember/engine';
import { InternalTransition as Transition } from 'router_js';
import { EMBER_ROUTING_ROUTER_SERVICE } from '@ember/canary-features';

let originalConsoleError;

Expand Down Expand Up @@ -2750,22 +2751,37 @@ moduleFor(
['@test Router `willTransition` hook passes in cancellable transition'](assert) {
// Should hit willTransition 3 times, once for the initial route, and then 2 more times
// for the two handleURL calls below
assert.expect(5);
if (EMBER_ROUTING_ROUTER_SERVICE) {
assert.expect(7);

this.router.reopen({
init() {
this._super(...arguments);
this.on('routeWillChange', transition => {
assert.ok(true, 'routeWillChange was called');
if (transition.intent && transition.intent.url !== '/') {
transition.abort();
}
});
},
});
} else {
assert.expect(5);
this.router.reopen({
willTransition(_, _2, transition) {
assert.ok(true, 'willTransition was called');
if (transition.intent.url !== '/') {
transition.abort();
}
},
});
}

this.router.map(function() {
this.route('nork');
this.route('about');
});

this.router.reopen({
willTransition(_, _2, transition) {
assert.ok(true, 'willTransition was called');
if (transition.intent.url !== '/') {
transition.abort();
}
},
});

this.add(
'route:loading',
Route.extend({
Expand Down Expand Up @@ -2922,13 +2938,17 @@ moduleFor(
this.router.map(function() {
this.route('nork');
});

this.router.reopen({
didTransition() {
this._super(...arguments);
assert.ok(true, 'reopened didTransition was called');
},
});
if (EMBER_ROUTING_ROUTER_SERVICE) {
assert.ok(true, 'no longer a valid test');
return;
} else {
this.router.reopen({
didTransition() {
this._super(...arguments);
assert.ok(true, 'reopened didTransition was called');
},
});
}

return this.visit('/');
}
Expand Down
8 changes: 5 additions & 3 deletions packages/ember/tests/routing/deprecated_handler_infos_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ if (EMBER_ROUTING_ROUTER_SERVICE) {

'@test handlerInfos are deprecated and associated private apis'(assert) {
let done = assert.async();
return this.visit('/parent').then(() => {
done();
});
expectDeprecation(() => {
return this.visit('/parent').then(() => {
done();
});
}, /You attempted to override the \"(willTransition|didTransition)\" method which is deprecated. Please inject the router service and listen to the \"(routeWillChange|routeDidChange)\" event\./);
}
}
);
Expand Down
158 changes: 77 additions & 81 deletions packages/ember/tests/routing/router_service_test/basic_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,90 @@ import { Route, NoneLocation } from '@ember/-internals/routing';
import { set } from '@ember/-internals/metal';
import { RouterTestCase, moduleFor } from 'internal-test-helpers';

import { EMBER_ROUTING_ROUTER_SERVICE } from '@ember/canary-features';
moduleFor(
'Router Service - main',
class extends RouterTestCase {
['@test RouterService#currentRouteName is correctly set for top level route'](assert) {
assert.expect(1);

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

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

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

if (EMBER_ROUTING_ROUTER_SERVICE) {
moduleFor(
'Router Service - main',
class extends RouterTestCase {
['@test RouterService#currentRouteName is correctly set for top level route'](assert) {
assert.expect(1);
['@test RouterService#currentRouteName is correctly set after transition'](assert) {
assert.expect(1);

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

['@test RouterService#currentRouteName is correctly set for child route'](assert) {
assert.expect(1);
['@test RouterService#currentRouteName is correctly set on each transition'](assert) {
assert.expect(3);

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

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

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

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

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

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

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

['@test RouterService#rootURL is correctly set to the default value'](assert) {
assert.expect(1);

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

['@test RouterService#rootURL is correctly set to a custom value'](assert) {
assert.expect(1);

this.add(
'route:parent.index',
Route.extend({
init() {
this._super();
set(this._router, 'rootURL', '/homepage');
},
})
);

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

['@test RouterService#location is correctly delegated from router:main'](assert) {
assert.expect(2);
return this.visit('/sister');
})
.then(() => {
assert.equal(this.routerService.get('currentRouteName'), 'parent.sister');

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

['@test RouterService#rootURL is correctly set to the default value'](assert) {
assert.expect(1);

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

['@test RouterService#rootURL is correctly set to a custom value'](assert) {
assert.expect(1);

this.add(
'route:parent.index',
Route.extend({
init() {
this._super();
set(this._router, 'rootURL', '/homepage');
},
})
);

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

['@test RouterService#location is correctly delegated from router:main'](assert) {
assert.expect(2);

return this.visit('/').then(() => {
let location = this.routerService.get('location');
assert.ok(location);
assert.ok(location instanceof NoneLocation);
});
}
}
);
Loading

0 comments on commit 0f95c77

Please sign in to comment.