Skip to content

Commit

Permalink
fix(854): Fix suspended user check (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdstar authored and tkyi committed Jul 25, 2018
1 parent b26073c commit 3565bbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class GithubScm extends Scm {
return repo.data.permissions;
} catch (err) {
// Suspended user
if (err.code === 404 && err.message.match(/suspend/i)) {
if (err.message.match(/suspend/i)) {
winston.info(
`User's account suspended for ${scmInfo.owner}/${scmInfo.repo}, ` +
'it will be removed from pipeline admins.');
Expand Down
5 changes: 2 additions & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,9 @@ describe('index', function () {
});
});

it('catches and discards Github errors when it has a 404 error code', () => {
it('catches and discards Github errors when it has a suspended user error message', () => {
const err = new Error('Sorry. Your account was suspended.');

err.code = 404;
githubMock.repos.get.yieldsAsync(err);

return scm.getPermissions(config)
Expand Down Expand Up @@ -430,7 +429,7 @@ describe('index', function () {
);
})
.catch(() => {
assert(false, 'Error should be handled if error code is 404');
assert(false, 'Error should be handled if error message has "suspend" string');
});
});
});
Expand Down

0 comments on commit 3565bbb

Please sign in to comment.