-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[CLEANUP beta] Remove Application Controller Router Properties #19707
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1848,16 +1848,11 @@ moduleFor( | |
|
||
await this.click('#about-link > a'); | ||
|
||
expectDeprecation(() => { | ||
let currentRouteName = this.applicationInstance | ||
.lookup('controller:application') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I this test should be retained with the other |
||
.get('currentRouteName'); | ||
assert.notEqual( | ||
currentRouteName, | ||
'about', | ||
'link-to should not transition if target is not equal to _self or empty' | ||
); | ||
}, 'Accessing `currentRouteName` on `controller:application` is deprecated, use the `currentRouteName` property on `service:router` instead.'); | ||
assert.notEqual( | ||
this.appRouter.currentRouteName, | ||
'about', | ||
'link-to should not transition if target is not equal to _self or empty' | ||
); | ||
} | ||
|
||
async [`@test it accepts string/numeric arguments`](assert) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { run } from '@ember/runloop'; | ||
import { get } from '@ember/-internals/metal'; | ||
import Controller from '@ember/controller'; | ||
import { Router } from '@ember/-internals/routing'; | ||
import { moduleFor, AutobootApplicationTestCase } from 'internal-test-helpers'; | ||
|
@@ -129,9 +128,7 @@ moduleFor( | |
let location = initialRouter.get('location'); | ||
|
||
assert.equal(location.getURL(), '/one'); | ||
expectDeprecation(() => { | ||
assert.equal(get(initialApplicationController, 'currentPath'), 'one'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to above, can this assertion be changed to assert the router service with This is an integration test, and I wouldn't want to lose the coverage that Ember's routing system in general is up to date after a visit call. |
||
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.'); | ||
assert.equal(initialRouter.currentPath, 'one'); | ||
|
||
this.application.reset(); | ||
|
||
|
@@ -160,9 +157,7 @@ moduleFor( | |
); | ||
|
||
assert.equal(location.getURL(), '/one'); | ||
expectDeprecation(() => { | ||
assert.equal(get(applicationController, 'currentPath'), 'one'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here as elsewhere in this file. |
||
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.'); | ||
assert.equal(router.currentPath, 'one'); | ||
}); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,14 +79,6 @@ moduleFor( | |
}); | ||
} | ||
|
||
get currentPath() { | ||
let currentPath; | ||
expectDeprecation(() => { | ||
currentPath = this.applicationInstance.lookup('controller:application').get('currentPath'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...and again here, use the router service. (I'm surprised these were not all refactored when the deprecation was added.) |
||
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.'); | ||
return currentPath; | ||
} | ||
|
||
async ['@test warn on URLs not included in the route set'](assert) { | ||
await this.visit('/'); | ||
|
||
|
@@ -95,7 +87,7 @@ moduleFor( | |
|
||
['@test The Homepage'](assert) { | ||
return this.visit('/').then(() => { | ||
assert.equal(this.currentPath, 'home', 'currently on the home route'); | ||
assert.equal(this.appRouter.currentPath, 'home', 'currently on the home route'); | ||
|
||
let text = this.$('.hours').text(); | ||
assert.equal(text, 'Hours', 'the home template was rendered'); | ||
|
@@ -109,15 +101,15 @@ moduleFor( | |
|
||
return this.visit('/camelot') | ||
.then(() => { | ||
assert.equal(this.currentPath, 'camelot'); | ||
assert.equal(this.appRouter.currentPath, 'camelot'); | ||
|
||
let text = this.$('#camelot').text(); | ||
assert.equal(text, 'Is a silly place', 'the camelot template was rendered'); | ||
|
||
return this.visit('/'); | ||
}) | ||
.then(() => { | ||
assert.equal(this.currentPath, 'home'); | ||
assert.equal(this.appRouter.currentPath, 'home'); | ||
|
||
let text = this.$('.hours').text(); | ||
assert.equal(text, 'Hours', 'the home template was rendered'); | ||
|
@@ -708,12 +700,12 @@ moduleFor( | |
1, | ||
'The home template was rendered' | ||
); | ||
assert.equal(this.currentPath, 'home'); | ||
assert.equal(this.appRouter.currentPath, 'home'); | ||
}); | ||
} | ||
|
||
['@test Redirecting from the middle of a route aborts the remainder of the routes'](assert) { | ||
assert.expect(5); | ||
assert.expect(4); | ||
|
||
this.router.map(function () { | ||
this.route('home'); | ||
|
@@ -750,21 +742,15 @@ moduleFor( | |
return this.visit('/').then(() => { | ||
let router = this.applicationInstance.lookup('router:main'); | ||
this.handleURLAborts(assert, '/foo/bar/baz'); | ||
let currentPath; | ||
expectDeprecation(() => { | ||
currentPath = this.applicationInstance | ||
.lookup('controller:application') | ||
.get('currentPath'); | ||
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.'); | ||
assert.equal(currentPath, 'home'); | ||
assert.equal(router.currentPath, 'home'); | ||
assert.equal(router.get('location').getURL(), '/home'); | ||
}); | ||
} | ||
|
||
['@test Redirecting to the current target in the middle of a route does not abort initial routing']( | ||
assert | ||
) { | ||
assert.expect(7); | ||
assert.expect(6); | ||
|
||
this.router.map(function () { | ||
this.route('home'); | ||
|
@@ -805,21 +791,15 @@ moduleFor( | |
|
||
return this.visit('/foo/bar/baz').then(() => { | ||
assert.ok(true, '/foo/bar/baz has been handled'); | ||
let currentPath; | ||
expectDeprecation(() => { | ||
currentPath = this.applicationInstance | ||
.lookup('controller:application') | ||
.get('currentPath'); | ||
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.'); | ||
assert.equal(currentPath, 'foo.bar.baz'); | ||
assert.equal(this.appRouter.currentPath, 'foo.bar.baz'); | ||
assert.equal(successCount, 1, 'transitionTo success handler was called once'); | ||
}); | ||
} | ||
|
||
['@test Redirecting to the current target with a different context aborts the remainder of the routes']( | ||
assert | ||
) { | ||
assert.expect(7); | ||
assert.expect(6); | ||
|
||
this.router.map(function () { | ||
this.route('home'); | ||
|
@@ -860,13 +840,7 @@ moduleFor( | |
|
||
return this.visit('/').then(() => { | ||
this.handleURLAborts(assert, '/foo/bar/1/baz'); | ||
let currentPath; | ||
expectDeprecation(() => { | ||
currentPath = this.applicationInstance | ||
.lookup('controller:application') | ||
.get('currentPath'); | ||
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.'); | ||
assert.equal(currentPath, 'foo.bar.baz'); | ||
assert.equal(this.appRouter.currentPath, 'foo.bar.baz'); | ||
assert.equal( | ||
this.applicationInstance.lookup('router:main').get('location').getURL(), | ||
'/foo/bar/2/baz' | ||
|
@@ -901,19 +875,11 @@ moduleFor( | |
|
||
return this.visit('/foo/bar/baz').then(() => { | ||
assert.ok(true, '/foo/bar/baz has been handled'); | ||
let applicationController = this.applicationInstance.lookup('controller:application'); | ||
let router = this.applicationInstance.lookup('router:main'); | ||
|
||
let currentPath; | ||
expectDeprecation(() => { | ||
currentPath = applicationController.get('currentPath'); | ||
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.'); | ||
assert.equal(currentPath, 'foo.bar.baz'); | ||
assert.equal(router.currentPath, 'foo.bar.baz'); | ||
run(() => router.send('goToQux')); | ||
expectDeprecation(() => { | ||
currentPath = applicationController.get('currentPath'); | ||
}, 'Accessing `currentPath` on `controller:application` is deprecated, use the `currentPath` property on `service:router` instead.'); | ||
assert.equal(currentPath, 'foo.qux'); | ||
assert.equal(router.currentPath, 'foo.qux'); | ||
assert.equal(router.get('location').getURL(), '/foo/qux'); | ||
}); | ||
} | ||
|
@@ -1405,10 +1371,10 @@ moduleFor( | |
}); | ||
} | ||
|
||
['@test currentRouteName is a property installed on ApplicationController that can be used in transitionTo']( | ||
['@test currentRouteName is a property installed on Router that can be used in transitionTo']( | ||
assert | ||
) { | ||
assert.expect(36); | ||
assert.expect(24); | ||
|
||
this.router.map(function () { | ||
this.route('index', { path: '/' }); | ||
|
@@ -1424,17 +1390,15 @@ moduleFor( | |
}); | ||
|
||
return this.visit('/').then(() => { | ||
let appController = this.applicationInstance.lookup('controller:application'); | ||
let router = this.applicationInstance.lookup('router:main'); | ||
|
||
function transitionAndCheck(path, expectedPath, expectedRouteName) { | ||
if (path) { | ||
run(router, 'transitionTo', path); | ||
} | ||
expectDeprecation(() => { | ||
assert.equal(appController.get('currentPath'), expectedPath); | ||
assert.equal(appController.get('currentRouteName'), expectedRouteName); | ||
}, /Accessing `(currentPath|currentRouteName)` on `controller:application` is deprecated, use the `(currentPath|currentRouteName)` property on `service:router` instead\./); | ||
|
||
assert.equal(router.currentPath, expectedPath); | ||
assert.equal(router.currentRouteName, expectedRouteName); | ||
} | ||
|
||
transitionAndCheck(null, 'index', 'index'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this test was specifically testing deprecated behavior, I think the deprecated API was only used during test of a legitimate behavior we want to retain.
I believe the right approach here is to refactor the test to use the router service instead of
currentRouteName
via the application controller, remove theexpectDeprecation(
code, and retain the test.Can you dig into it?