diff --git a/README.md b/README.md index 84d870dc..49b96332 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/github.js b/github.js index 6f8dc215..ec253d65 100644 --- a/github.js +++ b/github.js @@ -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 diff --git a/test/test.issue.js b/test/test.issue.js index e69de29b..e28ccb81 100644 --- a/test/test.issue.js +++ b/test/test.issue.js @@ -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(); + }); + }); + }); + + +}); \ No newline at end of file