Skip to content

Commit fc2806b

Browse files
author
Chris Moultrie
committed
Merge branch 'master' of git://github.com/andreacode/node-jira into merging
Conflicts: lib/jira.js
2 parents 7011868 + bbae5ff commit fc2806b

File tree

3 files changed

+110
-1
lines changed

3 files changed

+110
-1
lines changed

lib/jira.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@
112112
// * _0.0.3 Added APIs and Docco documentation_
113113
// * _0.0.2 Initial version_
114114
var url = require('url'),
115+
FormData = require('form-data'),
116+
fs = require('fs'),
115117
logger = console;
116118

117119

@@ -867,14 +869,23 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
867869
});
868870
};
869871

872+
<<<<<<< HEAD
870873
// ## List Components ##
871874
// ### Takes ###
872875
//
873876
// * project: key for the project
877+
=======
878+
// ## Assign issue in Jira ##
879+
// ### Takes ###
880+
//
881+
// * issueId: the Id of the issue to delete
882+
// * issueUpdate: username of the assignee
883+
>>>>>>> bbae5ff8ea8893449ee2d00000eb91dde4860dfc
874884
// * callback: for when it's done
875885
//
876886
// ### Returns ###
877887
// * error string
888+
<<<<<<< HEAD
878889
// * array of components
879890
//
880891
// [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290489)
@@ -910,12 +921,28 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
910921
};
911922

912923
this.request(options, function(error, response, body) {
924+
=======
925+
// * success string
926+
//
927+
// [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#idp1342720)
928+
this.assign = function(issueNum, assignee, callback) {
929+
var options = {
930+
rejectUnauthorized: this.strictSSL,
931+
uri: this.makeUri('/issue/' + issueNum + '/assignee'),
932+
json: {name: assignee},
933+
method: 'PUT',
934+
followAllRedirects: true
935+
};
936+
937+
this.request(options, function(error, response) {
938+
>>>>>>> bbae5ff8ea8893449ee2d00000eb91dde4860dfc
913939

914940
if (error) {
915941
callback(error, null);
916942
return;
917943
}
918944

945+
<<<<<<< HEAD
919946
if (response.statusCode === 200) {
920947
callback(null, body);
921948
return;
@@ -1027,6 +1054,14 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
10271054
}
10281055

10291056
callback(response.statusCode + ': Error while updating');
1057+
=======
1058+
if (response.statusCode === 204) {
1059+
callback(null, "Success");
1060+
return;
1061+
}
1062+
1063+
callback(response.statusCode + ': Error while assigning');
1064+
>>>>>>> bbae5ff8ea8893449ee2d00000eb91dde4860dfc
10301065

10311066
});
10321067
};
@@ -1146,6 +1181,61 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
11461181
});
11471182
};
11481183

1184+
<<<<<<< HEAD
1185+
=======
1186+
// ## Add attachment to issue ##
1187+
// ### Takes ###
1188+
//
1189+
// * issueId: the Id of the issue to delete
1190+
// * path: local path to the attachment
1191+
// * callback: for when it's done
1192+
//
1193+
// ### Returns ###
1194+
// * error string
1195+
// * success string
1196+
//
1197+
// [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#idp2051136)
1198+
this.attachToIssue = function(issueNum, path, callback) {
1199+
var self = this;
1200+
var options = {
1201+
rejectUnauthorized: this.strictSSL,
1202+
uri: this.makeUri('/issue/' + issueNum + '/attachments'),
1203+
method: 'POST',
1204+
followAllRedirects: true,
1205+
json: true,
1206+
headers: {
1207+
'x-atlassian-token': 'nocheck'
1208+
}
1209+
};
1210+
1211+
var form = new FormData();
1212+
form.append('file', fs.createReadStream(path));
1213+
1214+
form.getLength(function(err, length) {
1215+
1216+
var form_request = self.request(options, function(error, response) {
1217+
if (error) {
1218+
callback(error, null);
1219+
return;
1220+
}
1221+
1222+
if (response.statusCode === 200) {
1223+
callback(null, "Success");
1224+
return;
1225+
}
1226+
1227+
callback(response.statusCode + ': Error while uploading');
1228+
1229+
});
1230+
1231+
form_request.setHeader('Content-Length', length);
1232+
form = form_request.form();
1233+
form.append('file', fs.createReadStream(path));
1234+
});
1235+
1236+
};
1237+
1238+
>>>>>>> bbae5ff8ea8893449ee2d00000eb91dde4860dfc
11491239
// ## List all Viewable Projects ##
11501240
// ### Takes ###
11511241
//

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
}
2323
],
2424
"dependencies": {
25-
"request": "<2.16.0"
25+
"request": "<2.16.0",
26+
"form-data": "0.0.10"
2627
},
2728
"scripts": {
2829
"test": "grunt test"

spec/jira.spec.coffee

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,24 @@ describe "Node Jira Tests", ->
364364
@jira.request.mostRecentCall.args[1] null, statusCode:200
365365
expect(@cb).toHaveBeenCalledWith null, 'Success'
366366

367+
it "Assigns an Issue", ->
368+
options =
369+
rejectUnauthorized: true
370+
uri: makeUrl "issue/1/assignee"
371+
json: {name: 'newAssignee'}
372+
method: 'PUT'
373+
followAllRedirects: true
374+
375+
@jira.assign 1, 'newAssignee', @cb
376+
expect(@jira.request).toHaveBeenCalledWith options, jasmine.any(Function)
377+
378+
@jira.request.mostRecentCall.args[1] null, statusCode:400
379+
expect(@cb).toHaveBeenCalledWith '400: Error while assigning'
380+
381+
# Successful Request
382+
@jira.request.mostRecentCall.args[1] null, statusCode:204
383+
expect(@cb).toHaveBeenCalledWith null, 'Success'
384+
367385
it "Lists Transitions", ->
368386
options =
369387
rejectUnauthorized: true

0 commit comments

Comments
 (0)