Commit e5347172 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'fe-api-group-members' into 'master'

Add groupMembers to api.js

See merge request gitlab-org/gitlab-ce!24892
parents ad513afc d4e9dd96
......@@ -5,6 +5,7 @@ import axios from './lib/utils/axios_utils';
const Api = {
groupsPath: '/api/:version/groups.json',
groupPath: '/api/:version/groups/:id',
groupMembersPath: '/api/:version/groups/:id/members',
subgroupsPath: '/api/:version/groups/:id/subgroups',
namespacesPath: '/api/:version/namespaces.json',
groupProjectsPath: '/api/:version/groups/:id/projects.json',
......@@ -40,6 +41,12 @@ const Api = {
});
},
groupMembers(id) {
const url = Api.buildUrl(this.groupMembersPath).replace(':id', encodeURIComponent(id));
return axios.get(url);
},
// Return groups list. Filtered by query
groups(query, options, callback = $.noop) {
const url = Api.buildUrl(Api.groupsPath);
......
......@@ -49,6 +49,22 @@ describe('Api', () => {
});
});
describe('groupMembers', () => {
it('fetches group members', done => {
const groupId = '54321';
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${groupId}/members`;
const expectedData = [{ id: 7 }];
mock.onGet(expectedUrl).reply(200, expectedData);
Api.groupMembers(groupId)
.then(({ data }) => {
expect(data).toEqual(expectedData);
})
.then(done)
.catch(done.fail);
});
});
describe('groups', () => {
it('fetches groups', done => {
const query = 'dummy query';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment