Skip to content

Commit

Permalink
Merge branch 'master' into check-issue-templates
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Oct 11, 2018
2 parents a99712f + fab44ce commit 413fc86
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const IssueBodyChecker = require('./lib/IssueBodyChecker')
const getConfig = require('probot-config')

module.exports = robot => {
robot.on('installation_repositories.added', learningLabWelcome)
robot.on(['pull_request.opened', 'issues.opened'], receive)
async function receive (context) {
let title
Expand Down Expand Up @@ -65,4 +66,18 @@ module.exports = robot => {
}
}
}

// Say hi!
const NAME = 'introduction-to-github-apps'
async function learningLabWelcome (context) {
const includes = context.payload.repositories_added.some(r => r.name === NAME)
if (!includes) return

return context.github.issues.createComment({
owner: context.payload.installation.account.login,
repo: NAME,
number: 2,
body: 'Well done! You successfully installed the request info app.\n\n_disclaimer_ If you use this app in future repos, you won\'t get a message like this. This is just for Learning Lab!'
})
}
}
26 changes: 26 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,5 +560,31 @@ describe('Request info', () => {
})
})
})

describe('open issue on installation', () => {
let event

beforeEach(() => {
event = {
event: 'installation_repositories',
payload: {
action: 'added',
installation: { account: { login: 'BEXO' } },
repositories_added: [{ name: 'introduction-to-github-apps' }]
}
}
})

it('opens a new issue', async () => {
await robot.receive(event)
expect(github.issues.createComment).toHaveBeenCalled()
})

it('does not open a new issue if the repo name is not right', async () => {
event.payload.repositories_added = [{ name: 'NOT-introduction-to-github-apps' }]
await robot.receive(event)
expect(github.issues.createComment).toNotHaveBeenCalled()
})
})
})
})

0 comments on commit 413fc86

Please sign in to comment.