Skip to content

Added visibility support for comments #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/jira.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions spec/jira.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down