Skip to content

Commit

Permalink
Merge pull request #33 from cp4r3z/master
Browse files Browse the repository at this point in the history
Added addMemberToBoard
  • Loading branch information
norberteder authored Nov 17, 2016
2 parents 8493ce1 + cfdca5c commit 3334dd4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ Trello.prototype.addListToBoard = function (boardId, name, callback) {
return makeRequest(rest.post, this.uri + '/1/boards/' + boardId + '/lists', {query: query}, callback);
};

Trello.prototype.addMemberToBoard = function (boardId, memberId, type, callback) {
var query = this.createQuery();
var data = {type: type}; // Valid Values: 'normal','admin','observer'

return makeRequest(rest.put, this.uri + '/1/boards/' + boardId + '/members/' + memberId, { data: data, query: query }, callback);
};

Trello.prototype.addCommentToCard = function (cardId, comment, callback) {
var query = this.createQuery();
query.text = comment;
Expand Down
30 changes: 30 additions & 0 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,36 @@ describe('Trello', function () {
});
});

describe('addMemberToBoard', function () {
var data;
var post;

beforeEach(function (done) {
sinon.stub(restler, 'put', function (uri, options) {
return {once: function (event, callback) {
callback(null, null);
}};
});

trello.addMemberToBoard('boardId', 'memberId', 'normal', function () {
data = restler.put.args[0][1].data;
put = restler.put;
done();
});
});

it('should post to https://api.trello.com/1/boards/boardId/members/memberId', function () {
put.should.have.been.calledWith('https://api.trello.com/1/boards/boardId/members/memberId');
});

it('should include the type', function () {
data.type.should.equal('normal');
});

afterEach(function () {
restler.put.restore();
});
});

describe('addLabelOnBoard', function() {
var query;
Expand Down

0 comments on commit 3334dd4

Please sign in to comment.