Skip to content

Commit

Permalink
Added unstar() method
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelioDeRosa committed Jan 24, 2016
1 parent 1fd209d commit bc25f25
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 7 additions & 0 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion test/test.repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit bc25f25

Please sign in to comment.