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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
cb11d352
Commit
cb11d352
authored
Nov 22, 2016
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix IID filter for merge requests and milestones
parent
35d6ea4f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
9 deletions
+26
-9
doc/api/merge_requests.md
doc/api/merge_requests.md
+1
-1
doc/api/milestones.md
doc/api/milestones.md
+2
-2
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+3
-5
lib/api/milestones.rb
lib/api/milestones.rb
+1
-1
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+10
-0
spec/requests/api/milestones_spec.rb
spec/requests/api/milestones_spec.rb
+9
-0
No files found.
doc/api/merge_requests.md
View file @
cb11d352
...
@@ -10,7 +10,7 @@ The pagination parameters `page` and `per_page` can be used to restrict the list
...
@@ -10,7 +10,7 @@ The pagination parameters `page` and `per_page` can be used to restrict the list
GET /projects/:id/merge_requests
GET /projects/:id/merge_requests
GET /projects/:id/merge_requests?state=opened
GET /projects/:id/merge_requests?state=opened
GET /projects/:id/merge_requests?state=all
GET /projects/:id/merge_requests?state=all
GET /projects/:id/merge_requests?iid=42
GET /projects/:id/merge_requests?iid
[]
=42
```
```
Parameters:
Parameters:
...
...
doc/api/milestones.md
View file @
cb11d352
...
@@ -6,7 +6,7 @@ Returns a list of project milestones.
...
@@ -6,7 +6,7 @@ Returns a list of project milestones.
```
```
GET /projects/:id/milestones
GET /projects/:id/milestones
GET /projects/:id/milestones?iid=42
GET /projects/:id/milestones?iid
[]
=42
GET /projects/:id/milestones?state=active
GET /projects/:id/milestones?state=active
GET /projects/:id/milestones?state=closed
GET /projects/:id/milestones?state=closed
```
```
...
@@ -16,7 +16,7 @@ Parameters:
...
@@ -16,7 +16,7 @@ Parameters:
| Attribute | Type | Required | Description |
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| --------- | ---- | -------- | ----------- |
|
`id`
| integer | yes | The ID of a project |
|
`id`
| integer | yes | The ID of a project |
|
`iid`
|
integer
| optional | Return only the milestone having the given
`iid`
|
|
`iid`
|
Array[integer]
| optional | Return only the milestone having the given
`iid`
|
|
`state`
| string | optional | Return only
`active`
or
`closed`
milestones
` |
|
`state`
| string | optional | Return only
`active`
or
`closed`
milestones
` |
```bash
```bash
...
...
lib/api/merge_requests.rb
View file @
cb11d352
...
@@ -41,15 +41,13 @@ module API
...
@@ -41,15 +41,13 @@ module API
desc:
'Return merge requests ordered by `created_at` or `updated_at` fields.'
desc:
'Return merge requests ordered by `created_at` or `updated_at` fields.'
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'desc'
,
optional
:sort
,
type:
String
,
values:
%w[asc desc]
,
default:
'desc'
,
desc:
'Return merge requests sorted in `asc` or `desc` order.'
desc:
'Return merge requests sorted in `asc` or `desc` order.'
optional
:iid
,
type:
Integer
,
desc:
'The IID of the merge requests'
optional
:iid
,
type:
Array
[
Integer
]
,
desc:
'The IID of the merge requests'
end
end
get
":id/merge_requests"
do
get
":id/merge_requests"
do
authorize!
:read_merge_request
,
user_project
authorize!
:read_merge_request
,
user_project
merge_requests
=
user_project
.
merge_requests
.
inc_notes_with_associations
unless
params
[
:iid
].
nil?
merge_requests
=
user_project
.
merge_requests
.
inc_notes_with_associations
merge_requests
=
filter_by_iid
(
merge_requests
,
params
[
:iid
])
merge_requests
=
filter_by_iid
(
merge_requests
,
params
[
:iid
])
if
params
[
:iid
].
present?
end
merge_requests
=
merge_requests
=
case
params
[
:state
]
case
params
[
:state
]
...
...
lib/api/milestones.rb
View file @
cb11d352
...
@@ -28,7 +28,7 @@ module API
...
@@ -28,7 +28,7 @@ module API
params
do
params
do
optional
:state
,
type:
String
,
values:
%w[active closed all]
,
default:
'all'
,
optional
:state
,
type:
String
,
values:
%w[active closed all]
,
default:
'all'
,
desc:
'Return "active", "closed", or "all" milestones'
desc:
'Return "active", "closed", or "all" milestones'
optional
:iid
,
type:
Integer
,
desc:
'The IID of the milestone'
optional
:iid
,
type:
Array
[
Integer
]
,
desc:
'The IID of the milestone'
end
end
get
":id/milestones"
do
get
":id/milestones"
do
authorize!
:read_milestone
,
user_project
authorize!
:read_milestone
,
user_project
...
...
spec/requests/api/merge_requests_spec.rb
View file @
cb11d352
...
@@ -169,6 +169,16 @@ describe API::API, api: true do
...
@@ -169,6 +169,16 @@ describe API::API, api: true do
expect
(
json_response
.
first
[
'id'
]).
to
eq
merge_request
.
id
expect
(
json_response
.
first
[
'id'
]).
to
eq
merge_request
.
id
end
end
it
'returns merge_request by iid array'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests"
,
user
),
iid:
[
merge_request
.
iid
,
merge_request_closed
.
iid
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
merge_request_closed
.
title
expect
(
json_response
.
first
[
'id'
]).
to
eq
merge_request_closed
.
id
end
it
"returns a 404 error if merge_request_id not found"
do
it
"returns a 404 error if merge_request_id not found"
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/999"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/999"
,
user
)
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
to
have_http_status
(
404
)
...
...
spec/requests/api/milestones_spec.rb
View file @
cb11d352
...
@@ -61,6 +61,15 @@ describe API::API, api: true do
...
@@ -61,6 +61,15 @@ describe API::API, api: true do
expect
(
json_response
.
first
[
'id'
]).
to
eq
closed_milestone
.
id
expect
(
json_response
.
first
[
'id'
]).
to
eq
closed_milestone
.
id
end
end
it
'returns a project milestone by iid array'
do
get
api
(
"/projects/
#{
project
.
id
}
/milestones"
,
user
),
iid:
[
milestone
.
iid
,
closed_milestone
.
iid
]
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
.
size
).
to
eq
(
2
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
milestone
.
title
expect
(
json_response
.
first
[
'id'
]).
to
eq
milestone
.
id
end
it
'returns 401 error if user not authenticated'
do
it
'returns 401 error if user not authenticated'
do
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
"
)
get
api
(
"/projects/
#{
project
.
id
}
/milestones/
#{
milestone
.
id
}
"
)
...
...
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