diff --git a/src/github.js b/src/github.js index cb6546a5..009af105 100644 --- a/src/github.js +++ b/src/github.js @@ -458,6 +458,12 @@ _request('GET', repoPath + '/pulls/' + number, null, cb); }; + // List all collaborators of a repository + // ------- + this.listCollaborators = function(cb) { + _request('GET', repoPath + "/collaborators", null, cb); + }; + // Retrieve the changes made between base and head // ------- @@ -1024,6 +1030,28 @@ _requestAllPages(path + '?' + query.join('&'), cb); }; + this.events = function(options, cb) { + var query = []; + + for (var key in options) { + if (options.hasOwnProperty(key)) { + query.push(encodeURIComponent(key) + "=" + encodeURIComponent(options[key])); + } + } + _requestAllPages(path + '/events' + '?' + query.join("&"), cb); + }; + + this.comments = function(options, cb) { + var query = []; + + for (var key in options) { + if (options.hasOwnProperty(key)) { + query.push(encodeURIComponent(key) + "=" + encodeURIComponent(options[key])); + } + } + _requestAllPages(path + '/comments' + '?' + query.join("&"), cb); + }; + this.comment = function (issue, comment, cb) { _request('POST', issue.comments_url, { body: comment diff --git a/test/test.issue.js b/test/test.issue.js index a4c6c1a9..4f1d2ad3 100644 --- a/test/test.issue.js +++ b/test/test.issue.js @@ -44,6 +44,26 @@ describe('Github.Issue', function() { }); }); + it('should list events', function(done) { + issues.events(null, function(err, events, xhr) { + should.not.exist(err); + xhr.should.be.instanceof(XMLHttpRequest); + events.should.have.length.above(0); + + done(); + }); + }); + + it('should list comments', function(done) { + issues.comments(null, function(err, comments, xhr) { + should.not.exist(err); + xhr.should.be.instanceof(XMLHttpRequest); + comments.should.have.length.above(0); + + done(); + }); + }); + it('should post issue comment', function(done) { issues.comment(issue, 'Comment test', function(err, res, xhr) { should.not.exist(err); diff --git a/test/test.repo.js b/test/test.repo.js index bb405cdc..c5c99804 100644 --- a/test/test.repo.js +++ b/test/test.repo.js @@ -425,6 +425,18 @@ describe('Creating new Github.Repository', function() { }); }); + it('should list collaborators of repo', function(done) { + var repo = github.getRepo('michael', 'github'); + + repo.listCollaborators(function(err, collabs, xhr) { + should.not.exist(err); + xhr.should.be.instanceof(XMLHttpRequest); + + // @TODO write better assertion + done(); + }); + }); + it('should delete a file on the repo', function(done) { repo.write('master', 'REMOVE-TEST.md', 'THIS IS A TEST', 'Remove test', function(err) { should.not.exist(err);