Skip to content

Commit

Permalink
fix(send-stale-inital-pr-reminder): don't try to comment if we alread…
Browse files Browse the repository at this point in the history
…y commented
  • Loading branch information
Realtin committed Jul 4, 2017
1 parent 8df97e0 commit 5e9a10a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions jobs/send-stale-initial-pr-reminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = async function (
const ghqueue = githubQueue(installationId)

if (repository.enabled) return
if (repository.staleInitialPRReminder) return

const [owner, repo] = repository.fullName.split('/')

Expand Down
27 changes: 27 additions & 0 deletions test/jobs/send-stale-initial-pr-reminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,33 @@ test('send-stale-initial-pr-reminder', async t => {
await waitFor(50)
})

t.test('does nothing if the repo has already received the reminder', async t => {
t.plan(1)

await upsert(repositories, '42', {staleInitialPRReminder: true})

githubNock
.get('/repos/finnp/test/issues/1234')
.reply(200, () => {
t.fail('Should not query issue status')
return {}
})
.post('/repos/finnp/test/issues/1234/comments')
.reply(201, () => {
t.fail('Should not post comment')
return {}
})

const newJob = await worker({
prNumber: 1234,
repositoryId: 42,
accountId: 123
})

t.notOk(newJob, 'no new job')
await waitFor(50)
})

t.test('does nothing if the issue was closed in the meanwhile', async t => {
t.plan(1)

Expand Down

0 comments on commit 5e9a10a

Please sign in to comment.