Skip to content
Open
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
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ declare class TestrailApiClient {

getUser(id: number, callback?: t.Callback<t.ITestrailUser>): t.PromiseResponse<t.ITestrailUser>;
getUserByEmail(email: string, callback?: t.Callback<t.ITestrailUser>): t.PromiseResponse<t.ITestrailUser>;
getUsers(callback?: t.Callback<t.ITestrailUser[]>): t.PromiseResponse<t.ITestrailUser[]>;
getUsers(project_id?: number, callback?: t.Callback<t.ITestrailUser[]>): t.PromiseResponse<t.ITestrailUser[]>;
}

declare namespace TestrailApiClient {
Expand Down
15 changes: 13 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,19 @@ TestRail.prototype.getUserByEmail = function (email, callback) {
return this.apiGet('get_user_by_email', {email: email}, callback);
};

TestRail.prototype.getUsers = function (callback) {
return this.apiGet('get_users', callback);
TestRail.prototype.getUsers = function (project_id, callback) {
var url = 'get_users';

if (typeof project_id === 'function') {
callback = project_id;
project_id = undefined;
}

if (project_id !== undefined) {
url += '/' + project_id;
}

return this.apiGet(url, callback);
};

// ----------
Expand Down
14 changes: 14 additions & 0 deletions test/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ describe('users api', function() {
{ 'id': 2, 'name': 'Ciaran Davenport' }
]);

nock('https://rundef.testrail.com')
.get(testrail.uri + 'get_users/10')
.reply(200, [
{ 'id': 1, 'name': 'Alexis Gonzalez' },
]);



Expand Down Expand Up @@ -82,4 +87,13 @@ describe('users api', function() {
done();
});
});

it('Get all by project', function (done) {
testrail.getUsers(10, function (err, response, body) {
expect(err).to.be.null;
expect(response).to.be.an.object;
expect(body).to.be.an.array;
done();
});
});
});