mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-16 02:44:19 +08:00
@@ -5,6 +5,7 @@ module.exports = {
|
||||
label: require('./actions/label'),
|
||||
lock: require('./actions/lock'),
|
||||
open: require('./actions/open'),
|
||||
unassign: require('./actions/unassign'),
|
||||
unlabel: require('./actions/unlabel'),
|
||||
unlock: require('./actions/unlock'),
|
||||
react: require('./actions/react'),
|
||||
|
||||
17
lib/actions/unassign.js
Normal file
17
lib/actions/unassign.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// Unassign one or more users from an issue or pull request.
|
||||
//
|
||||
// ```yml
|
||||
// - then:
|
||||
// # Unassign a single user
|
||||
// unassign: bkeeepers
|
||||
//
|
||||
// # Unassign multiple users
|
||||
// unassign: [bkeeepers, benbalter]
|
||||
// ```
|
||||
//
|
||||
|
||||
module.exports = function (github, payload, logins) {
|
||||
return github.issues.removeAssigneesFromIssue(
|
||||
payload.toIssue({body: {assignees: [].concat(logins)}})
|
||||
);
|
||||
};
|
||||
@@ -14,7 +14,8 @@
|
||||
"github": "^5.2.0",
|
||||
"github-webhook-handler": "^0.6.0",
|
||||
"handlebars": "^4.0.5",
|
||||
"js-yaml": "^3.6.1"
|
||||
"js-yaml": "^3.6.1",
|
||||
"jsdoc": "^3.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^3.0.2",
|
||||
|
||||
34
test/actions/unassign.js
Normal file
34
test/actions/unassign.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const expect = require('expect');
|
||||
const action = require('../../lib/actions/unassign');
|
||||
const Payload = require('../../lib/payload');
|
||||
const payload = new Payload(require('../fixtures/webhook/comment.created.json'));
|
||||
|
||||
const createSpy = expect.createSpy;
|
||||
|
||||
const github = {
|
||||
issues: {
|
||||
removeAssigneesFromIssue: createSpy()
|
||||
}
|
||||
};
|
||||
|
||||
describe('action.unassign', () => {
|
||||
it('unassigns a user', () => {
|
||||
action(github, payload, 'bkeepers');
|
||||
expect(github.issues.removeAssigneesFromIssue).toHaveBeenCalledWith({
|
||||
owner: 'bkeepers-inc',
|
||||
repo: 'test',
|
||||
number: 6,
|
||||
body: {assignees: ['bkeepers']}
|
||||
});
|
||||
});
|
||||
|
||||
it('unassigns multiple users', () => {
|
||||
action(github, payload, ['hello', 'world']);
|
||||
expect(github.issues.removeAssigneesFromIssue).toHaveBeenCalledWith({
|
||||
owner: 'bkeepers-inc',
|
||||
repo: 'test',
|
||||
number: 6,
|
||||
body: {assignees: ['hello', 'world']}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user