Skip to content
Closed
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ To read all the issues of a given repository
issues.list(options, function(err, issues) {});
```

To comment in a issue

```js
issues.comment(issue, comment,function(err, comment) {});
```

##Setup

Github.js has the following dependency:
Expand Down
8 changes: 8 additions & 0 deletions github.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,14 @@
}
_requestAllPages(path + '?' + query.join("&"), cb);
};

this.comment = function(issue, comment, cb) {
_request("POST", issue.comments_url, {body:comment}, function(err,res) {
cb(err,res);
});
};


};

// Top Level API
Expand Down
36 changes: 36 additions & 0 deletions test/test.issue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

var test = require('tape'); //jshint ignore:line
var Github = require("../");
var test_user = require('./user.json');

test("Issues API", function(t) {
var github = new Github({
username: test_user.USERNAME,
password: test_user.PASSWORD,
auth: "basic"
});

var issues = github.getIssues('mikedeboertest', 'TestRepo');

t.test('issues.list', function(q) {
issues.list({},function(err, issues) {
q.error(err);
t.equals(issues.length > 0, true, 'Issues!');
q.end();
});
t.end();
});

t.test('issues.comment', function(q) {
issues.list({},function(err, issuesList) {
issues.comment(issuesList[0], 'Comment test', function(err, res){
q.error(err);
t.equals(res.body, 'Comment test', 'Comments!');
q.end();
});
});
});


});