Skip to content

Commit

Permalink
[BUGFIX release] Ensure handleURL called after setURL in visit helper
Browse files Browse the repository at this point in the history
Refs #11201
  • Loading branch information
jaswilli committed Jun 1, 2015
1 parent f932861 commit 2b44d90
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/ember-testing/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
24 changes: 24 additions & 0 deletions packages/ember-testing/tests/acceptance_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ QUnit.module("ember-testing Acceptance", {
this.route('comments');

this.route('abort_transition');

this.route('redirect');
});

App.IndexRoute = EmberRoute.extend({
Expand Down Expand Up @@ -67,6 +69,12 @@ QUnit.module("ember-testing Acceptance", {
}
});

App.RedirectRoute = EmberRoute.extend({
beforeModel() {
this.transitionTo('comments');
}
});

App.setupForTesting();
});

Expand Down Expand Up @@ -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');
});
});

0 comments on commit 2b44d90

Please sign in to comment.