Merge pull request #20 from bkeepers/unassign

Add unassign action
This commit is contained in:
Brandon Keepers
2016-10-12 15:49:16 -05:00
committed by GitHub
4 changed files with 54 additions and 1 deletions

View File

@@ -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
View 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)}})
);
};

View File

@@ -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
View 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']}
});
});
});