Skip to content

Commit 3dc854a

Browse files
dafortuneAurelioDeRosa
authored andcommitted
Added create issue
Closes gh-291
1 parent 9335b8c commit 3dc854a

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,23 @@ To read all the issues of a given repository
386386
issues.list(options, function(err, issues) {});
387387
```
388388

389+
To create an issue
390+
391+
```js
392+
var options = {
393+
title: "Found a bug",
394+
body: "I'm having a problem with this.",
395+
assignee: "assignee_username",
396+
milestone: 1,
397+
labels: [
398+
"Label1",
399+
"Label2"
400+
]
401+
};
402+
403+
issues.create(options, function(err, issue) {});
404+
```
405+
389406
To comment in a issue
390407

391408
```js

src/github.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,10 @@
10081008
Github.Issue = function (options) {
10091009
var path = '/repos/' + options.user + '/' + options.repo + '/issues';
10101010

1011+
this.create = function(options, cb) {
1012+
_request('POST', path, options, cb);
1013+
};
1014+
10111015
this.list = function (options, cb) {
10121016
var query = [];
10131017

@@ -1115,4 +1119,4 @@
11151119
};
11161120

11171121
return Github;
1118-
}));
1122+
}));

test/test.issue.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ describe('Github.Issue', function() {
1717
issues = github.getIssues(testUser.USERNAME, 'TestRepo');
1818
});
1919

20+
it('should create issue', function(done) {
21+
issues.create({
22+
title: 'New issue',
23+
body: 'New issue body'
24+
}, function(err, issue, xhr) {
25+
should.not.exist(err);
26+
xhr.should.be.instanceof(XMLHttpRequest);
27+
should.exist(issue.url);
28+
issue.title.should.equal('New issue');
29+
issue.body.should.equal('New issue body');
30+
31+
done();
32+
});
33+
});
34+
2035
it('should list issues', function(done) {
2136
issues.list({}, function(err, issues, xhr) {
2237
should.not.exist(err);

0 commit comments

Comments
 (0)