Skip to content

Commit

Permalink
fix(stateQueueManager): Use location: true for url-matched transitions
Browse files Browse the repository at this point in the history
closes #2455
  • Loading branch information
christopherthielen committed Mar 6, 2016
1 parent 5d1f50f commit 25e0c04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/state/stateQueueManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class StateQueueManager {

$urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) {
if ($state.$current.navigable !== state || !equalForKeys($match, $stateParams)) {
$state.transitionTo(state, $match, { inherit: true, location: false });
$state.transitionTo(state, $match, { inherit: true });
}
}]);
}
Expand Down
20 changes: 20 additions & 0 deletions test/stateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2027,3 +2027,23 @@ describe('otherwise and state redirects', function() {
expect($state.current.name).toBe("loginPage")
}));
});


describe('hook redirects from .otherwise()', function() {
beforeEach(module(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('home', { url: '/home', template: 'home' })
.state('loginPage', { url: '/login', template: 'login' });
}));

// Test for #2455
it("should go to the redirect-to target state and url", inject(function($transitions, $q, $state, $location) {
$transitions.onBefore({ to: 'home' }, function() {
return $state.target('loginPage', {}, { location: true });
});
$q.flush();
expect($state.current.name).toBe("loginPage");
expect($location.path()).toBe('/login');
}));
});

0 comments on commit 25e0c04

Please sign in to comment.