From bc25f25adaa666b60a819d863f4f6136afe3da7d Mon Sep 17 00:00:00 2001 From: Aurelio De Rosa Date: Sun, 24 Jan 2016 17:42:42 +0000 Subject: [PATCH] Added unstar() method --- README.md | 6 ++++++ src/github.js | 7 +++++++ test/test.repo.js | 13 ++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e4cc176a..36c23cad 100644 --- a/README.md +++ b/README.md @@ -250,6 +250,12 @@ Star a repository. repo.star(owner, repository, function(err) {}); ``` +Unstar a repository. + +```js +repo.unstar(owner, repository, function(err) {}); +``` + ## User API diff --git a/src/github.js b/src/github.js index 744a0cc7..20abc455 100644 --- a/src/github.js +++ b/src/github.js @@ -859,6 +859,13 @@ this.star = function(owner, repository, cb) { _request('PUT', '/user/starred/' + owner + '/' + repository, null, cb) }; + + // Unstar a repository. + // -------- + + this.unstar = function(owner, repository, cb) { + _request('DELETE', '/user/starred/' + owner + '/' + repository, null, cb) + }; }; // Gists API diff --git a/test/test.repo.js b/test/test.repo.js index fa600ead..5c7ddf67 100644 --- a/test/test.repo.js +++ b/test/test.repo.js @@ -37,7 +37,7 @@ if (typeof window === 'undefined') { // We're in NodeJS } } -describe.only('Github.Repository', function() { +describe('Github.Repository', function() { before(function() { github = new Github({ username: testUser.USERNAME, @@ -516,6 +516,17 @@ describe('Creating new Github.Repository', function() { }); }); }); + + it('should unstar the repo', function(done) { + repo.unstar(testUser.USERNAME, repoTest, function(err) { + should.not.exist(err); + + repo.isStarred(testUser.USERNAME, repoTest, function(err) { + err.error.should.equal(404); + done(); + }); + }); + }); }); describe('deleting a Github.Repository', function() {