Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
fix(greenkeeper-url): updated to match the new expected url
Browse files Browse the repository at this point in the history
  • Loading branch information
travi committed Sep 22, 2018
1 parent 219b818 commit 3120615
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/greenkeeper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const GREENKEEPER_BOT_GITHUB_URL = 'https://github.com/greenkeeperio-bot';
export const GREENKEEPER_BOT_GITHUB_URL = 'https://github.com/marketplace/greenkeeper';
export const GREENKEEPER_INTEGRATION_GITHUB_URL = 'https://github.com/apps/greenkeeper';

export default function (sender) {
Expand Down
5 changes: 3 additions & 2 deletions src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ export default async function (request, responseToolkit, settings) {
return responseToolkit.response(boom.internal('too many PRs exist for this commit'));
}

if (openedByGreenkeeperBot(pullRequests[0].user.html_url)) {
const senderUrl = pullRequests[0].user.html_url;
if (openedByGreenkeeperBot(senderUrl)) {
process(request, await getPullRequest(repository, pullRequests[0].number), settings);
return responseToolkit.response('ok').code(ACCEPTED);
}

return responseToolkit.response('PR is not from greenkeeper').code(BAD_REQUEST);
return responseToolkit.response(`PR is not from greenkeeper, but from ${senderUrl}`).code(BAD_REQUEST);
})
.catch(e => boom.internal('failed to fetch PRs', e));
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/greenkeeper-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import openedByGreenkeeperBot, {

suite('greenkeeper', () => {
test('that the users are defined to match the greenkeeper bots', () => {
assert.equal(GREENKEEPER_BOT_GITHUB_URL, 'https://github.com/greenkeeperio-bot');
assert.equal(GREENKEEPER_BOT_GITHUB_URL, 'https://github.com/marketplace/greenkeeper');
assert.equal(GREENKEEPER_INTEGRATION_GITHUB_URL, 'https://github.com/apps/greenkeeper');
});

Expand Down
5 changes: 3 additions & 2 deletions test/unit/handler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,14 @@ suite('handler', () => {
});

test('that the response is bad-request if the PR is not from greenkeeper', () => {
const senderUrl = any.url();
const request = {
payload: {state: 'success', branches: [{name: any.string()}]},
headers: {'x-github-event': 'status'},
log: () => undefined
};
getPullRequestsForCommit.resolves([{user: {html_url: any.url()}}]);
response.withArgs('PR is not from greenkeeper').returns({code});
getPullRequestsForCommit.resolves([{user: {html_url: senderUrl}}]);
response.withArgs(`PR is not from greenkeeper, but from ${senderUrl}`).returns({code});

return handler(request, {response}, settings).then(() => assert.calledWith(code, BAD_REQUEST));
});
Expand Down

0 comments on commit 3120615

Please sign in to comment.