diff --git a/lib/jira.js b/lib/jira.js index e919d9da..85f69fb2 100644 --- a/lib/jira.js +++ b/lib/jira.js @@ -1442,13 +1442,21 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor // * issueId: Issue to add a comment to // * comment: string containing comment // * callback: for when it's done + // * [visibility]: visibility of comment, optional // // ### Returns ### // * error string // * success string // // [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#id108798) - this.addComment = function(issueId, comment, callback){ + /** + * Visibility object format + * { + * "type": "role", + * "value": "Administrators" + * } + */ + this.addComment = function(issueId, comment, callback, visibility){ var options = { rejectUnauthorized: this.strictSSL, uri: this.makeUri('/issue/' + issueId + '/comment'), @@ -1460,6 +1468,10 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor json: true }; + if (visibility) { + options.body.visibility = visibility; + } + this.doRequest(options, function(error, response, body) { if (error) { callback(error, null); diff --git a/spec/jira.spec.coffee b/spec/jira.spec.coffee index 716d0c9d..911c8398 100644 --- a/spec/jira.spec.coffee +++ b/spec/jira.spec.coffee @@ -527,6 +527,10 @@ describe "Node Jira Tests", -> user: 'test' pass: 'test' + visibility = + type: "role" + value: "Administrators" + @jira.addComment 1, 'aComment', @cb expect(@jira.request).toHaveBeenCalledWith options, jasmine.any(Function) @@ -538,6 +542,13 @@ describe "Node Jira Tests", -> @jira.request.mostRecentCall.args[1] null, statusCode:201 expect(@cb).toHaveBeenCalledWith null, "Success" + # Comments with predetermined level of visibility + @jira.request.reset() + @jira.addComment 1, "aComment", @cb, visibility + #extend options object + options.body.visibility = visibility + expect(@jira.request).toHaveBeenCalledWith options, jasmine.any(Function) + it "Adds a worklog to a project", -> options = rejectUnauthorized: true