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
9039fd94
Commit
9039fd94
authored
Mar 06, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
2eea8e1b
f1185520
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
469 additions
and
60 deletions
+469
-60
app/services/issuable_base_service.rb
app/services/issuable_base_service.rb
+1
-1
lib/api/issues.rb
lib/api/issues.rb
+2
-2
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+3
-3
lib/api/validations/types/labels_list.rb
lib/api/validations/types/labels_list.rb
+24
-0
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+211
-7
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+197
-47
spec/support/shared_examples/requests/api/merge_requests_list.rb
...pport/shared_examples/requests/api/merge_requests_list.rb
+31
-0
No files found.
app/services/issuable_base_service.rb
View file @
9039fd94
...
@@ -89,7 +89,7 @@ class IssuableBaseService < BaseService
...
@@ -89,7 +89,7 @@ class IssuableBaseService < BaseService
return
unless
labels
return
unless
labels
params
[
:label_ids
]
=
labels
.
split
(
","
).
map
do
|
label_name
|
params
[
:label_ids
]
=
labels
.
map
do
|
label_name
|
label
=
Labels
::
FindOrCreateService
.
new
(
label
=
Labels
::
FindOrCreateService
.
new
(
current_user
,
current_user
,
parent
,
parent
,
...
...
lib/api/issues.rb
View file @
9039fd94
...
@@ -36,7 +36,7 @@ module API
...
@@ -36,7 +36,7 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
params
:issues_params
do
params
:issues_params
do
optional
:labels
,
type:
String
,
desc:
'Comma-separated list of label names'
optional
:labels
,
type:
Array
[
String
],
coerce_with:
Validations
::
Types
::
LabelsList
.
coerce
,
desc:
'Comma-separated list of label names'
optional
:milestone
,
type:
String
,
desc:
'Milestone title'
optional
:milestone
,
type:
String
,
desc:
'Milestone title'
optional
:order_by
,
type:
String
,
values:
%w[created_at updated_at]
,
default:
'created_at'
,
optional
:order_by
,
type:
String
,
values:
%w[created_at updated_at]
,
default:
'created_at'
,
desc:
'Return issues ordered by `created_at` or `updated_at` fields.'
desc:
'Return issues ordered by `created_at` or `updated_at` fields.'
...
@@ -67,7 +67,7 @@ module API
...
@@ -67,7 +67,7 @@ module API
optional
:assignee_ids
,
type:
Array
[
Integer
],
desc:
'The array of user IDs to assign issue'
optional
:assignee_ids
,
type:
Array
[
Integer
],
desc:
'The array of user IDs to assign issue'
optional
:assignee_id
,
type:
Integer
,
desc:
'[Deprecated] The ID of a user to assign issue'
optional
:assignee_id
,
type:
Integer
,
desc:
'[Deprecated] The ID of a user to assign issue'
optional
:milestone_id
,
type:
Integer
,
desc:
'The ID of a milestone to assign issue'
optional
:milestone_id
,
type:
Integer
,
desc:
'The ID of a milestone to assign issue'
optional
:labels
,
type:
String
,
desc:
'Comma-separated list of label names'
optional
:labels
,
type:
Array
[
String
],
coerce_with:
Validations
::
Types
::
LabelsList
.
coerce
,
desc:
'Comma-separated list of label names'
optional
:due_date
,
type:
String
,
desc:
'Date string in the format YEAR-MONTH-DAY'
optional
:due_date
,
type:
String
,
desc:
'Date string in the format YEAR-MONTH-DAY'
optional
:confidential
,
type:
Boolean
,
desc:
'Boolean parameter if the issue should be confidential'
optional
:confidential
,
type:
Boolean
,
desc:
'Boolean parameter if the issue should be confidential'
optional
:discussion_locked
,
type:
Boolean
,
desc:
" Boolean parameter indicating if the issue's discussion is locked"
optional
:discussion_locked
,
type:
Boolean
,
desc:
" Boolean parameter indicating if the issue's discussion is locked"
...
...
lib/api/merge_requests.rb
View file @
9039fd94
...
@@ -97,7 +97,7 @@ module API
...
@@ -97,7 +97,7 @@ module API
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
:milestone
,
type:
String
,
desc:
'Return merge requests for a specific milestone'
optional
:milestone
,
type:
String
,
desc:
'Return merge requests for a specific milestone'
optional
:labels
,
type:
String
,
desc:
'Comma-separated list of label names'
optional
:labels
,
type:
Array
[
String
],
coerce_with:
Validations
::
Types
::
LabelsList
.
coerce
,
desc:
'Comma-separated list of label names'
optional
:created_after
,
type:
DateTime
,
desc:
'Return merge requests created after the specified time'
optional
:created_after
,
type:
DateTime
,
desc:
'Return merge requests created after the specified time'
optional
:created_before
,
type:
DateTime
,
desc:
'Return merge requests created before the specified time'
optional
:created_before
,
type:
DateTime
,
desc:
'Return merge requests created before the specified time'
optional
:updated_after
,
type:
DateTime
,
desc:
'Return merge requests updated after the specified time'
optional
:updated_after
,
type:
DateTime
,
desc:
'Return merge requests updated after the specified time'
...
@@ -181,8 +181,8 @@ module API
...
@@ -181,8 +181,8 @@ module API
optional
:description
,
type:
String
,
desc:
'The description of the merge request'
optional
:description
,
type:
String
,
desc:
'The description of the merge request'
optional
:assignee_id
,
type:
Integer
,
desc:
'The ID of a user to assign the merge request'
optional
:assignee_id
,
type:
Integer
,
desc:
'The ID of a user to assign the merge request'
optional
:milestone_id
,
type:
Integer
,
desc:
'The ID of a milestone to assign the merge request'
optional
:milestone_id
,
type:
Integer
,
desc:
'The ID of a milestone to assign the merge request'
optional
:labels
,
type:
String
,
desc:
'Comma-separated list of label names'
optional
:labels
,
type:
Array
[
String
],
coerce_with:
Validations
::
Types
::
LabelsList
.
coerce
,
desc:
'Comma-separated list of label names'
optional
:remove_source_branch
,
type:
Boolean
,
desc:
'
Delet
e source branch when merging'
optional
:remove_source_branch
,
type:
Boolean
,
desc:
'
Remov
e source branch when merging'
optional
:allow_collaboration
,
type:
Boolean
,
desc:
'Allow commits from members who can merge to the target branch'
optional
:allow_collaboration
,
type:
Boolean
,
desc:
'Allow commits from members who can merge to the target branch'
optional
:allow_maintainer_to_push
,
type:
Boolean
,
as: :allow_collaboration
,
desc:
'[deprecated] See allow_collaboration'
optional
:allow_maintainer_to_push
,
type:
Boolean
,
as: :allow_collaboration
,
desc:
'[deprecated] See allow_collaboration'
optional
:squash
,
type:
Grape
::
API
::
Boolean
,
desc:
'When true, the commits will be squashed into a single commit on merge'
optional
:squash
,
type:
Grape
::
API
::
Boolean
,
desc:
'When true, the commits will be squashed into a single commit on merge'
...
...
lib/api/validations/types/labels_list.rb
0 → 100644
View file @
9039fd94
# frozen_string_literal: true
module
API
module
Validations
module
Types
class
LabelsList
def
self
.
coerce
lambda
do
|
value
|
case
value
when
String
value
.
split
(
','
).
map
(
&
:strip
)
when
Array
value
.
map
{
|
v
|
v
.
to_s
.
split
(
','
).
map
(
&
:strip
)
}.
flatten
when
LabelsList
value
else
[]
end
end
end
end
end
end
end
spec/requests/api/issues_spec.rb
View file @
9039fd94
This diff is collapsed.
Click to expand it.
spec/requests/api/merge_requests_spec.rb
View file @
9039fd94
This diff is collapsed.
Click to expand it.
spec/support/shared_examples/requests/api/merge_requests_list.rb
View file @
9039fd94
...
@@ -186,6 +186,37 @@ shared_examples 'merge requests list' do
...
@@ -186,6 +186,37 @@ shared_examples 'merge requests list' do
expect
(
json_response
.
length
).
to
eq
(
0
)
expect
(
json_response
.
length
).
to
eq
(
0
)
end
end
it
'returns an array of labeled merge requests where all labels match'
do
path
=
endpoint_path
+
"?labels[]=
#{
label
.
title
}
&labels[]=
#{
label2
.
title
}
"
get
api
(
path
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label2
.
title
,
label
.
title
])
end
it
'returns an array of merge requests with any label when filtering by any label'
do
get
api
(
endpoint_path
,
user
),
params:
{
labels:
[
"
#{
label
.
title
}
"
,
"
#{
label2
.
title
}
"
]
}
expect_paginated_array_response
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label2
.
title
,
label
.
title
])
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
merge_request
.
id
)
end
it
'returns an array of merge requests with any label when filtering by any label'
do
get
api
(
endpoint_path
,
user
),
params:
{
labels:
[
"
#{
label
.
title
}
,
#{
label2
.
title
}
"
]
}
expect_paginated_array_response
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label2
.
title
,
label
.
title
])
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
merge_request
.
id
)
end
it
'returns an array of merge requests with any label when filtering by any label'
do
it
'returns an array of merge requests with any label when filtering by any label'
do
get
api
(
endpoint_path
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
get
api
(
endpoint_path
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
...
...
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