Add GET routes for /user/tags and /user/tags/{id}

An operation that is useful for tools to be able to do is to list a
user's tags without having to pull down the entire user object (which is
likely significantly larger than the tags). This commit adds a route to
GET /user/tags, to get a list of the user's tags, as well as a GET
/user/tags/{id} to get the details of a particular tag.

This commit also includes tests for the two new routes.
This commit is contained in:
Carlo Zancanaro
2015-10-20 00:50:41 +11:00
parent c04b27ffd5
commit 4d6bd38648
4 changed files with 72 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
import {
generateUser,
requester,
} from '../../helpers/api.helper';
describe('GET /user/tags', () => {
let api, user;
beforeEach(() => {
return generateUser().then((usr) => {
user = usr;
api = requester(usr);
});
});
it('gets the user\'s tags', () => {
return expect(api.get('/user/tags'))
.to.eventually.eql(user.tags);
});
});
+25
View File
@@ -0,0 +1,25 @@
import {
generateUser,
requester,
} from '../../helpers/api.helper';
describe('GET /user/tags/id', () => {
let api, user;
beforeEach(() => {
return generateUser().then((usr) => {
user = usr;
api = requester(usr);
});
});
it('gets a user\'s tag by id', () => {
return expect(api.get('/user/tags/' + user.tags[0].id))
.to.eventually.eql(user.tags[0]);
});
it('fails for non-existent tags', () => {
return expect(api.get('/user/tags/not-an-id'))
.to.eventually.be.rejected.with.property('code', 404);
});
});