diff --git a/packages/ember-testing/lib/helpers.js b/packages/ember-testing/lib/helpers.js index 88ccccf952e..0702a683a28 100644 --- a/packages/ember-testing/lib/helpers.js +++ b/packages/ember-testing/lib/helpers.js @@ -59,14 +59,13 @@ function visit(app, url) { var router = app.__container__.lookup('router:main'); app.boot().then(function() { router.location.setURL(url); + run(app.__deprecatedInstance__, 'handleURL', url); }); if (app._readinessDeferrals > 0) { router['initialURL'] = url; run(app, 'advanceReadiness'); delete router['initialURL']; - } else { - run(app.__deprecatedInstance__, 'handleURL', url); } return app.testHelpers.wait(); diff --git a/packages/ember-testing/tests/acceptance_test.js b/packages/ember-testing/tests/acceptance_test.js index bc74127e9cb..214a45523c8 100644 --- a/packages/ember-testing/tests/acceptance_test.js +++ b/packages/ember-testing/tests/acceptance_test.js @@ -30,6 +30,8 @@ QUnit.module("ember-testing Acceptance", { this.route('comments'); this.route('abort_transition'); + + this.route('redirect'); }); App.IndexRoute = EmberRoute.extend({ @@ -67,6 +69,12 @@ QUnit.module("ember-testing Acceptance", { } }); + App.RedirectRoute = EmberRoute.extend({ + beforeModel() { + this.transitionTo('comments'); + } + }); + App.setupForTesting(); }); @@ -355,3 +363,19 @@ QUnit.test("test must not finish while asyncHelpers are pending", function () { }); } }); + +QUnit.test('visiting a URL and then visiting a second URL with a transition should yield the correct URL', function () { + expect(2); + + visit('/posts'); + + andThen(function () { + equal(currentURL(), '/posts', 'First visited URL is correct'); + }); + + visit('/redirect'); + + andThen(function () { + equal(currentURL(), '/comments', 'Redirected to Comments URL'); + }); +});