Skip to content

Commit

Permalink
Merge pull request #14 from ilbonzo/pipelines
Browse files Browse the repository at this point in the history
feat (Lib) added move issue between pipelines
  • Loading branch information
ilbonzo authored Nov 9, 2018
2 parents 39960f1 + b2dff75 commit 048954d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ api.boards.getBoard('[repoId]', callback);
- [getIssue](https://github.com/ZenHubIO/API#get-issue-data)
- [getIssueEvents](https://github.com/ZenHubIO/API#get-issue-events)
- [setEstimateForIssue](https://github.com/ZenHubIO/API#set-estimate-for-issue)
- [moveIssueBetweenPipelines](https://github.com/ZenHubIO/API#move-an-issue-between-pipelines)

**Boards**
- [getBoard](https://github.com/ZenHubIO/API#get-the-zenhub-board-data-for-a-repository)
Expand Down
22 changes: 19 additions & 3 deletions lib/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,30 @@ Issues.prototype.getIssueEvents = function (repoId, issueNumber, callback) {
* Set estimate in issue
* This method set estimate for an issue on Issues.
* @param int repoId github id of repository
* @param int issueId github id of issue to convert
* @param int issueNumber github id of issue
* @param object payload contains estimate to set for the issue, see https://github.com/IssuesIO/API#set-estimate-for-issue for payload format
* @callback complete
* @memberof Issues
* @method setEstimateForIssue
*/
Issues.prototype.setEstimateForIssue = function (repoId, issueId, payload, callback) {
this._http._put('repositories/' + repoId + '/issues/' + issueId + '/estimate', {}, payload, function (error, body) {
Issues.prototype.setEstimateForIssue = function (repoId, issueNumber, payload, callback) {
this._http._put('repositories/' + repoId + '/issues/' + issueNumber + '/estimate', {}, payload, function (error, body) {
callback(error, body);
});
};

/**
* Moves an issue between the Pipelines in your repository.
*
* @param int repoId github id of repository
* @param int issue_number github id of issue to convert
* @param object payload see https://github.com/ZenHubIO/API#move-an-issue-between-pipelines for payload format
* @callback complete
* @memberof Issues
* @method moveIssueBetweenPipelines
*/
Issues.prototype.moveIssueBetweenPipelines = function (repoId, issueNumber, payload, callback) {
this._http._post('repositories/' + repoId + '/issues/' + issueNumber + '/moves', {}, payload, function (error, body) {
callback(error, body);
});
};
Expand Down
39 changes: 25 additions & 14 deletions test/zenhubWriteTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,31 @@ describe('ZenHub Write API', function() {
assert(nock.isDone(), 'not all expected HTTP requests were made');
});

describe('Issues test', function() {
var issueId = 457;

it('Set estimate for issue test', function(done) {
var payload = {
estimate: 8
};
nock('https://api.zenhub.io/p1')
.put('/repositories/' + repoId + '/issues/' + issueId + '/estimate' + tokenQueryString, payload)
.reply(200, { status: 'OK' });
api.issues.setEstimateForIssue(repoId, issueId, payload, done);
});

it('Move issue between pipelines test', function(done) {
var payload = {
pipeline_id: '595d430add03f01d32460080',
position: 1
};
nock('https://api.zenhub.io/p1')
.post('/repositories/' + repoId + '/issues/' + issueId + '/moves' + tokenQueryString, payload)
.reply(200, { status: 'OK' });
api.issues.moveIssueBetweenPipelines(repoId, issueId, payload, done);
});
});

describe('Add/remove issues to epic test', function() {
var epicId = 123;

Expand Down Expand Up @@ -77,20 +102,6 @@ describe('ZenHub Write API', function() {
});
});

describe('Set estimate for issue test', function() {
var issueId = 457;

it('should send payload to the ZenHub API', function(done) {
var payload = {
estimate: 8
};
nock('https://api.zenhub.io/p1')
.put('/repositories/' + repoId + '/issues/' + issueId + '/estimate' + tokenQueryString, payload)
.reply(200, { status: 'OK' });
api.issues.setEstimateForIssue(repoId, issueId, payload, done);
});
});

describe('Set start_date for milestone test', function() {
var milestoneNumber = 457;

Expand Down

0 comments on commit 048954d

Please sign in to comment.