Skip to content

Commit b7b7523

Browse files
committed
Added support for new estimate when adding worklog.
1 parent 991b15b commit b7b7523

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

lib/jira.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,10 +1355,14 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
13551355
* "id": "100028"
13561356
* }
13571357
*/
1358-
this.addWorklog = function(issueId, worklog, callback) {
1358+
this.addWorklog = function(issueId, worklog, newEstimate, callback) {
1359+
if(typeof callback == 'undefined') {
1360+
callback = newEstimate
1361+
newEstimate = false
1362+
}
13591363
var options = {
13601364
rejectUnauthorized: this.strictSSL,
1361-
uri: this.makeUri('/issue/' + issueId + '/worklog'),
1365+
uri: this.makeUri('/issue/' + issueId + '/worklog' + (newEstimate ? "?adjustEstimate=new&newEstimate=" + newEstimate : "")),
13621366
body: worklog,
13631367
method: 'POST',
13641368
followAllRedirects: true,

spec/jira.spec.coffee

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,35 @@ describe "Node Jira Tests", ->
529529
@jira.request.mostRecentCall.args[1] null, statusCode:201
530530
expect(@cb).toHaveBeenCalledWith null, "Success"
531531

532+
it "Adds a worklog to a project with remaining time set", ->
533+
options =
534+
rejectUnauthorized: true
535+
uri: makeUrl "issue/1/worklog?adjustEstimate=new&newEstimate=1h"
536+
body: 'aWorklog'
537+
method: 'POST'
538+
followAllRedirects: true
539+
json: true
540+
auth:
541+
user: 'test'
542+
pass: 'test'
543+
544+
@jira.addWorklog 1, 'aWorklog', '1h', @cb
545+
expect(@jira.request).toHaveBeenCalledWith options, jasmine.any(Function)
546+
547+
@jira.request.mostRecentCall.args[1] null, statusCode:400,
548+
'{"body:"none"}'
549+
expect(@cb).toHaveBeenCalledWith 'Invalid Fields: "{\\"body:\\"none\\"}"'
550+
551+
@jira.request.mostRecentCall.args[1] null, statusCode:403
552+
expect(@cb).toHaveBeenCalledWith 'Insufficient Permissions'
553+
554+
@jira.request.mostRecentCall.args[1] null, statusCode:401
555+
expect(@cb).toHaveBeenCalledWith '401: Error while updating'
556+
557+
# Successful Request
558+
@jira.request.mostRecentCall.args[1] null, statusCode:201
559+
expect(@cb).toHaveBeenCalledWith null, "Success"
560+
532561
it "Lists Issue Types", ->
533562
options =
534563
rejectUnauthorized: true

0 commit comments

Comments
 (0)