BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
5cc9ebbe
Commit
5cc9ebbe
authored
Feb 17, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '22018-api-milestone-merge-requests' into 'master'
Add API endpoint to get all milestone merge requests Closes #22018 See merge request !9298
parents
35824650
aa7c8be5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
0 deletions
+76
-0
22018-api-milestone-merge-requests.yml
changelogs/unreleased/22018-api-milestone-merge-requests.yml
+4
-0
milestones.md
doc/api/milestones.md
+14
-0
milestones.rb
lib/api/milestones.rb
+22
-0
milestones_spec.rb
spec/requests/api/milestones_spec.rb
+36
-0
No files found.
changelogs/unreleased/22018-api-milestone-merge-requests.yml
0 → 100644
View file @
5cc9ebbe
---
title
:
Adds API endpoint to fetch all merge request for a single milestone
merge_request
:
author
:
Joren De Groof
doc/api/milestones.md
View file @
5cc9ebbe
...
...
@@ -103,3 +103,16 @@ Parameters:
- `
id
` (required) - The ID of a project
- `
milestone_id
` (required) - The ID of a project milestone
## Get all merge requests assigned to a single milestone
Gets all merge requests assigned to a single project milestone.
```
GET /projects/:id/milestones/:milestone_id/merge_requests
```
Parameters:
- `
id
` (required) - The ID of a project
- `
milestone_id
`
(required) - The ID of a project milestone
\ No newline at end of file
lib/api/milestones.rb
View file @
5cc9ebbe
...
...
@@ -120,6 +120,28 @@ module API
issues
=
IssuesFinder
.
new
(
current_user
,
finder_params
).
execute
present
paginate
(
issues
),
with:
Entities
::
Issue
,
current_user:
current_user
,
project:
user_project
end
desc
'Get all merge requests for a single project milestone'
do
detail
'This feature was introduced in GitLab 9.'
success
Entities
::
MergeRequest
end
params
do
requires
:milestone_id
,
type:
Integer
,
desc:
'The ID of a project milestone'
use
:pagination
end
get
':id/milestones/:milestone_id/merge_requests'
do
authorize!
:read_milestone
,
user_project
milestone
=
user_project
.
milestones
.
find
(
params
[
:milestone_id
])
finder_params
=
{
project_id:
user_project
.
id
,
milestone_id:
milestone
.
id
}
merge_requests
=
MergeRequestsFinder
.
new
(
current_user
,
finder_params
).
execute
present
paginate
(
merge_requests
),
with:
Entities
::
MergeRequest
,
current_user:
current_user
,
project:
user_project
end
end
end
end
spec/requests/api/milestones_spec.rb
View file @
5cc9ebbe
...
...
@@ -229,4 +229,40 @@ describe API::Milestones, api: true do
end
end
end
describe
'GET /projects/:id/milestones/:milestone_id/merge_requests'
do
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
)
}
before
do
milestone
.
merge_requests
<<
merge_request
end
it
'returns project merge_requests for a particular milestone'
do
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
/merge_requests"
,
user
)
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
size
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
merge_request
.
title
)
expect
(
json_response
.
first
[
'milestone'
][
'title'
]).
to
eq
(
milestone
.
title
)
end
it
'returns a 404 error if milestone id not found'
do
get
api
(
"/projects/
#{
project
.
id
}
/milestones/1234/merge_requests"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
end
it
'returns a 404 if the user has no access to the milestone'
do
new_user
=
create
:user
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
/merge_requests"
,
new_user
)
expect
(
response
).
to
have_http_status
(
404
)
end
it
'returns a 401 error if user not authenticated'
do
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
/merge_requests"
)
expect
(
response
).
to
have_http_status
(
401
)
end
end
end
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