Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
778c705f
Commit
778c705f
authored
Jun 19, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added forked projects API call function
Part of
https://gitlab.com/gitlab-org/gitlab-ce/issues/58583
parent
8716eb0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+16
-0
spec/frontend/api_spec.js
spec/frontend/api_spec.js
+23
-0
No files found.
app/assets/javascripts/api.js
View file @
778c705f
...
@@ -12,6 +12,7 @@ const Api = {
...
@@ -12,6 +12,7 @@ const Api = {
groupProjectsPath
:
'
/api/:version/groups/:id/projects.json
'
,
groupProjectsPath
:
'
/api/:version/groups/:id/projects.json
'
,
projectsPath
:
'
/api/:version/projects.json
'
,
projectsPath
:
'
/api/:version/projects.json
'
,
projectPath
:
'
/api/:version/projects/:id
'
,
projectPath
:
'
/api/:version/projects/:id
'
,
forkedProjectsPath
:
'
/api/:version/projects/:id/forks
'
,
projectLabelsPath
:
'
/:namespace_path/:project_path/-/labels
'
,
projectLabelsPath
:
'
/:namespace_path/:project_path/-/labels
'
,
projectMergeRequestsPath
:
'
/api/:version/projects/:id/merge_requests
'
,
projectMergeRequestsPath
:
'
/api/:version/projects/:id/merge_requests
'
,
projectMergeRequestPath
:
'
/api/:version/projects/:id/merge_requests/:mrid
'
,
projectMergeRequestPath
:
'
/api/:version/projects/:id/merge_requests/:mrid
'
,
...
@@ -113,6 +114,21 @@ const Api = {
...
@@ -113,6 +114,21 @@ const Api = {
return
axios
.
get
(
url
);
return
axios
.
get
(
url
);
},
},
/**
* Get all projects for a forked relationship to a specified project
* @param {string} projectPath - Path or ID of a project
* @param {Object} params - Get request parameters
* @returns {Promise} - Request promise
*/
projectForks
(
projectPath
,
params
)
{
const
url
=
Api
.
buildUrl
(
Api
.
forkedProjectsPath
).
replace
(
'
:id
'
,
encodeURIComponent
(
projectPath
),
);
return
axios
.
get
(
url
,
{
params
});
},
/**
/**
* Get all Merge Requests for a project, eventually filtering based on
* Get all Merge Requests for a project, eventually filtering based on
* supplied parameters
* supplied parameters
...
...
spec/frontend/api_spec.js
View file @
778c705f
...
@@ -474,4 +474,27 @@ describe('Api', () => {
...
@@ -474,4 +474,27 @@ describe('Api', () => {
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
projectForks
'
,
()
=>
{
it
(
'
gets forked projects
'
,
done
=>
{
const
dummyProjectPath
=
'
gitlab-org/gitlab-ce
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/
${
encodeURIComponent
(
dummyProjectPath
,
)}
/forks`
;
jest
.
spyOn
(
axios
,
'
get
'
);
mock
.
onGet
(
expectedUrl
).
replyOnce
(
200
,
[
'
fork
'
]);
Api
.
projectForks
(
dummyProjectPath
,
{
visibility
:
'
private
'
})
.
then
(({
data
})
=>
{
expect
(
data
).
toEqual
([
'
fork
'
]);
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
expectedUrl
,
{
params
:
{
visibility
:
'
private
'
},
});
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment