Thanks to visit codestin.com
Credit goes to github.com

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
28 changes: 28 additions & 0 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
// -------

Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions test/test.issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions test/test.repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down