Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions client/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ module.exports = [
controller: 'IndexController',
controllerAs: 'COS',
resolve: {
user: function ($state, fetchUser, keypather) {
return fetchUser()
.then(function (user) {
var prevLocation = keypather.get(user, 'attrs.userOptions.uiState.previousLocation.org');
var prevInstance = keypather.get(user, 'attrs.userOptions.uiState.previousLocation.instance');
user: function ($q, $state, fetchUser, fetchGrantedGithubOrgs, keypather) {
return $q.all({ user: fetchUser(), grantedOrgs: fetchGrantedGithubOrgs() })
.then(function (userAndGrantedOrgs) {
var prevLocation = keypather.get(userAndGrantedOrgs, 'user.attrs.userOptions.uiState.previousLocation.org');
var prevInstance = keypather.get(userAndGrantedOrgs, 'user.attrs.userOptions.uiState.previousLocation.instance');
if (prevLocation) {
if (prevInstance) {
$state.go('base.instances.instance', {
Expand All @@ -59,10 +59,14 @@ module.exports = [
userName: prevLocation
});
}
} else if (!keypather.get(userAndGrantedOrgs, 'grantedOrgs.models.length')) {
$state.go('base.instances', {
userName: keypather.get(userAndGrantedOrgs, 'user.attrs.accounts.github.username')
});
} else {
$state.go('orgSelect');
}
return user;
return userAndGrantedOrgs.user;
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/services/serviceFetch.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('serviceFetch'.bold.underline.blue, function () {
var fetchUserPromise = fetchUser();
$rootScope.$digest();
expect(fetchUserPromise, 'Returned err').to.eventually.rejectedWith(err);
expect(windowMock.location).to.equal('https://runnable.com');
expect(windowMock.location).to.equal('https://runnable.io');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should this actually be?

});
});

Expand Down