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:
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user