Comparing version 0.1.6 to 0.2.0
@@ -34,3 +34,4 @@ module.exports = function(grunt) { | ||
project_id: "4321", | ||
ccb_issue_type: 20 | ||
ccb_issue_type: 20, | ||
ccb_done_state: 11 | ||
}, | ||
@@ -37,0 +38,0 @@ project: { |
{ | ||
"name": "grunt-ccb", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"description": "Create a CCB with manfiest information in JIRA", | ||
@@ -5,0 +5,0 @@ "main": "Gruntfile.js", |
@@ -35,3 +35,4 @@ # grunt-ccb | ||
project_id: 12100, | ||
ccb_issue_type: 20 | ||
ccb_issue_type: 20, | ||
ccb_done_state: 11 | ||
}, | ||
@@ -58,2 +59,3 @@ project: { | ||
- `ccb_issue_type` - Jira id of the type of issue to post the ccb as | ||
- `ccb_done_state` - The transition id to end the ccb workflow | ||
- `project` - TODO: We should use the properties in the package.json here | ||
@@ -60,0 +62,0 @@ - `name` - Name of the project that is creating the ccb (displayed in the ccb subject) |
@@ -66,3 +66,3 @@ 'use string'; | ||
else if (response.statusCode >= 300 ) { | ||
deferred.reject("Bad response: " + response); | ||
deferred.reject(response.statusCode + " - bad response: " + JSON.stringify(response)); | ||
} | ||
@@ -79,4 +79,4 @@ else { | ||
var updateCcbToInDevelopmentState = function(ccbId){ | ||
grunt.verbose.writeln("Updating CCB to 'In development' state"); | ||
var updateCcbToDone = function(ccbId){ | ||
grunt.verbose.writeln("Updating CCB to 'Done' state"); | ||
@@ -100,3 +100,3 @@ var deferred = q.defer(); | ||
{ | ||
"id": "11" | ||
"id": options.jira.ccb_done_state | ||
} | ||
@@ -109,3 +109,3 @@ } | ||
else if (response.statusCode >= 300 ) { | ||
deferred.reject("Bad response: " + response); | ||
deferred.reject(response.statusCode + " - bad response: " + JSON.stringify(response)); | ||
} | ||
@@ -120,48 +120,6 @@ else { | ||
var closeCcb = function(ccbId){ | ||
grunt.verbose.writeln("Updating CCB to 'Closed' state"); | ||
var deferred = q.defer(); | ||
request({ | ||
url: options.jira.api_url + util.format("issue/%s/transitions", ccbId), | ||
headers: { | ||
"Content-Type": "application/json", | ||
"User-Agent" : "Node Request" | ||
}, | ||
method: 'POST', | ||
auth: { | ||
user: options.jira.user, | ||
pass: options.jira.password | ||
}, | ||
proxy: options.jira.proxy, | ||
json: { | ||
"transition": | ||
{ | ||
"id": "21" | ||
} | ||
} | ||
}, function(error, response, body){ | ||
if (error) { | ||
deferred.reject(error); | ||
} | ||
else if (response.statusCode >= 300 ) { | ||
deferred.reject("Bad response: " + response); | ||
} | ||
else { | ||
deferred.resolve(); | ||
} | ||
}); | ||
return deferred.promise; | ||
}; | ||
createCbb() | ||
.then(function(ccbId){ | ||
return updateCcbToInDevelopmentState(ccbId); | ||
return updateCcbToDone(ccbId); | ||
}) | ||
.then(function(ccbId){ | ||
return closeCcb(ccbId); | ||
}) | ||
.catch(function(error){ | ||
@@ -168,0 +126,0 @@ grunt.fatal(error); |
@@ -39,6 +39,6 @@ var should = require('should'), | ||
describe('issuing the transition ticket to in-development request', function(){ | ||
describe('issuing the transition ticket to done request', function(){ | ||
var actual = JSON.parse(fs.readFileSync('tests/data/actual/in-dev-transition-request.json')); | ||
var expected = JSON.parse(fs.readFileSync('tests/data/expected/in-dev-transition-request.json')); | ||
var actual = JSON.parse(fs.readFileSync('tests/data/actual/done-transition-request.json')); | ||
var expected = JSON.parse(fs.readFileSync('tests/data/expected/done-transition-request.json')); | ||
@@ -61,23 +61,1 @@ it('should set the host correctly', function(){ | ||
}); | ||
describe('issuing the close ticket request', function(){ | ||
var actual = JSON.parse(fs.readFileSync('tests/data/actual/close-transition-request.json')); | ||
var expected = JSON.parse(fs.readFileSync('tests/data/expected/close-transition-request.json')); | ||
it('should set the host correctly', function(){ | ||
actual.headers.host.should.be.equal(expected.headers.host); | ||
}); | ||
it('should set authorization header correctly', function(){ | ||
actual.headers.authorization.should.be.equal(expected.headers.authorization); | ||
}); | ||
it('should set url correctly', function(){ | ||
actual.url.should.be.equal(expected.url); | ||
}); | ||
it('should send the correct body', function(){ | ||
actual.body.should.be.eql(expected.body); | ||
}); | ||
}); |
@@ -6,4 +6,3 @@ var http = require("http"), | ||
createCbbRequest = fs.openSync('tests/data/actual/ccb-request.json', 'w'), | ||
inDevTransitionRequest = fs.openSync('tests/data/actual/in-dev-transition-request.json', 'w'), | ||
closeTransitionRequest = fs.openSync('tests/data/actual/close-transition-request.json', 'w'); | ||
doneTransitionRequest = fs.openSync('tests/data/actual/done-transition-request.json', 'w'); | ||
@@ -33,11 +32,7 @@ module.exports = function(grunt){ | ||
} | ||
else if (bodyJson.transition.id === "11"){ //in-development | ||
else if (bodyJson.transition.id === 11){ //done | ||
fs.writeSync(inDevTransitionRequest, JSON.stringify({ headers: request.headers, url: request.url, body: bodyJson })); | ||
fs.writeSync(doneTransitionRequest, JSON.stringify({ headers: request.headers, url: request.url, body: bodyJson })); | ||
response.writeHead(200, {"Content-Type": "application/json"}); | ||
} else if (bodyJson.transition.id === "21"){ //close | ||
fs.writeSync(closeTransitionRequest, JSON.stringify({ headers: request.headers, url: request.url, body: bodyJson })); | ||
response.writeHead(200, {"Content-Type": "application/json"}); | ||
} | ||
@@ -44,0 +39,0 @@ response.end(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63
15037
13
242