diff --git a/package.json b/package.json index 291fca0b330..47b00832c31 100644 --- a/package.json +++ b/package.json @@ -148,7 +148,7 @@ "puppeteer": "^1.11.0", "qunit": "^2.8.0", "route-recognizer": "^0.3.4", - "router_js": "^6.2.1", + "router_js": "^6.2.2", "rsvp": "^4.8.4", "semver": "^5.5.0", "serve-static": "^1.13.2", diff --git a/packages/ember/tests/routing/decoupled_basic_test.js b/packages/ember/tests/routing/decoupled_basic_test.js index 286f8e6b4e9..503d52005b9 100644 --- a/packages/ember/tests/routing/decoupled_basic_test.js +++ b/packages/ember/tests/routing/decoupled_basic_test.js @@ -41,10 +41,20 @@ moduleFor( return this.applicationInstance.lookup(`controller:${name}`); } - handleURLAborts(assert, path) { + handleURLAborts(assert, path, deprecated) { run(() => { let router = this.applicationInstance.lookup('router:main'); - router.handleURL(path).then( + let result; + + if (deprecated !== undefined) { + expectDeprecation(() => { + result = router.handleURL(path); + }); + } else { + result = router.handleURL(path); + } + + result.then( function() { assert.ok(false, 'url: `' + path + '` was NOT to be handled'); }, @@ -2749,33 +2759,15 @@ 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 - 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(); - } - }, - }); - } + assert.expect(8); + 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'); @@ -2809,10 +2801,14 @@ moduleFor( }) ); - return this.visit('/').then(() => { - this.handleURLAborts(assert, '/nork'); - this.handleURLAborts(assert, '/about'); - }); + let deprecation = /You attempted to override the "willTransition" method which is deprecated\./; + + return expectDeprecation(() => { + return this.visit('/').then(() => { + this.handleURLAborts(assert, '/nork', deprecation); + this.handleURLAborts(assert, '/about', deprecation); + }); + }, deprecation); } ['@test Aborting/redirecting the transition in `willTransition` prevents LoadingRoute from being entered']( diff --git a/packages/ember/tests/routing/router_service_test/basic_test.js b/packages/ember/tests/routing/router_service_test/basic_test.js index 9dbf901fe9c..601ce099d6f 100644 --- a/packages/ember/tests/routing/router_service_test/basic_test.js +++ b/packages/ember/tests/routing/router_service_test/basic_test.js @@ -79,6 +79,28 @@ moduleFor( }); } + '@test substates survive aborts GH#17430'(assert) { + assert.expect(2); + this.add( + `route:parent.child`, + Route.extend({ + beforeModel(transition) { + transition.abort(); + this.intermediateTransitionTo('parent.sister'); + }, + }) + ); + + return this.visit('/') + .then(() => { + return this.routerService.transitionTo('/child'); + }) + .catch(e => { + assert.equal(this.routerService.currentRouteName, 'parent.sister'); + assert.equal(e.message, 'TransitionAborted'); + }); + } + ['@test RouterService#currentRouteName is correctly set on each transition'](assert) { if (EMBER_ROUTING_ROUTER_SERVICE) { assert.expect(9); diff --git a/yarn.lock b/yarn.lock index 358a6f94bc3..f7fbff524c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7441,10 +7441,10 @@ route-recognizer@^0.3.4: resolved "https://registry.yarnpkg.com/route-recognizer/-/route-recognizer-0.3.4.tgz#39ab1ffbce1c59e6d2bdca416f0932611e4f3ca3" integrity sha512-2+MhsfPhvauN1O8KaXpXAOfR/fwe8dnUXVM+xw7yt40lJRfPVQxV6yryZm0cgRvAj5fMF/mdRZbL2ptwbs5i2g== -router_js@^6.2.1: - version "6.2.1" - resolved "https://registry.yarnpkg.com/router_js/-/router_js-6.2.1.tgz#60130764ad3ed41592a41b9a0bb9133b3edc7d84" - integrity sha512-DL0FPuLZUkk7/mhIcXK3SO7215gyOVcQinPtdcLRHKJDt8GGqN6c0pNr0+vuE1IQX7QW1YyuIxBICZ0egzn8Dg== +router_js@^6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/router_js/-/router_js-6.2.2.tgz#173fe28f004d437a150a42be8220a0341d8df4d8" + integrity sha512-gjNl8cxJYHXxLKe/BimTuXLANAb6AVIpK5nK4XvY5d5Do69RMr80YrNFmfHvgD31p0qXUDlz3+fcfAn7ylqIjg== dependencies: "@types/node" "^10.5.5"