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
Léo-Paul Géneau
gitlab-ce
Commits
aa7c8be5
Commit
aa7c8be5
authored
Feb 16, 2017
by
Joren De Groof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API endpoint to get all milestone merge requests
parent
b08be165
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
0 deletions
+75
-0
changelogs/unreleased/22018-api-milestone-merge-requests.yml
changelogs/unreleased/22018-api-milestone-merge-requests.yml
+4
-0
doc/api/milestones.md
doc/api/milestones.md
+13
-0
lib/api/milestones.rb
lib/api/milestones.rb
+22
-0
spec/requests/api/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 @
aa7c8be5
---
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 @
aa7c8be5
...
...
@@ -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 @
aa7c8be5
...
...
@@ -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 @
aa7c8be5
...
...
@@ -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