Commit 80c553d2 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'get-group-milestones-api.js' into 'master'

Add group milestones API method to api.js

Closes #232520

See merge request gitlab-org/gitlab!39280
parents 0568efa2 029c864c
......@@ -9,6 +9,7 @@ const Api = {
groupsPath: '/api/:version/groups.json',
groupPath: '/api/:version/groups/:id',
groupMembersPath: '/api/:version/groups/:id/members',
groupMilestonesPath: '/api/:version/groups/:id/milestones',
subgroupsPath: '/api/:version/groups/:id/subgroups',
namespacesPath: '/api/:version/namespaces.json',
groupPackagesPath: '/api/:version/groups/:id/packages',
......@@ -110,6 +111,17 @@ const Api = {
});
},
groupMilestones(id, options) {
const url = Api.buildUrl(this.groupMilestonesPath).replace(':id', encodeURIComponent(id));
return axios.get(url, {
params: {
per_page: DEFAULT_PER_PAGE,
...options,
},
});
},
// Return groups list. Filtered by query
groups(query, options, callback = () => {}) {
const url = Api.buildUrl(Api.groupsPath);
......
......@@ -149,6 +149,36 @@ describe('Api', () => {
});
});
describe('groupMilestones', () => {
it('fetches group milestones', done => {
const groupId = '16';
const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${groupId}/milestones`;
const expectedData = [
{
id: 12,
iid: 3,
group_id: 16,
title: '10.0',
description: 'Version',
due_date: '2013-11-29',
start_date: '2013-11-10',
state: 'active',
updated_at: '2013-10-02T09:24:18Z',
created_at: '2013-10-02T09:24:18Z',
web_url: 'https://gitlab.com/groups/gitlab-org/-/milestones/42',
},
];
mock.onGet(expectedUrl).reply(httpStatus.OK, expectedData);
Api.groupMilestones(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