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
0588cb65
Commit
0588cb65
authored
Mar 08, 2019
by
Alexandru Croitor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for coerced labels parameter in Epics API
parent
2796beaa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
4 deletions
+140
-4
ee/changelogs/unreleased/epic-api-labels-spec.yml
ee/changelogs/unreleased/epic-api-labels-spec.yml
+5
-0
ee/spec/requests/api/epics_spec.rb
ee/spec/requests/api/epics_spec.rb
+135
-4
No files found.
ee/changelogs/unreleased/epic-api-labels-spec.yml
0 → 100644
View file @
0588cb65
---
title
:
Add specs for coerced labels parameter in Epics API
merge_request
:
9932
author
:
type
:
other
ee/spec/requests/api/epics_spec.rb
View file @
0588cb65
...
...
@@ -203,6 +203,108 @@ describe API::Epics do
expect_paginated_array_response
([
epic2
.
id
])
end
it
'returns an array of labeled epics with labels param as array'
do
get
api
(
url
,
user
),
params:
{
labels:
[
label
.
title
]
}
expect_paginated_array_response
([
epic2
.
id
])
end
it
'returns an array of labeled epics when all labels matches'
do
label_b
=
create
(
:group_label
,
title:
'foo'
,
group:
group
)
label_c
=
create
(
:label
,
title:
'bar'
,
project:
project
)
create
(
:label_link
,
label:
label_b
,
target:
epic2
)
create
(
:label_link
,
label:
label_c
,
target:
epic2
)
get
api
(
url
,
user
),
params:
{
labels:
"
#{
label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
}
expect_paginated_array_response
([
epic2
.
id
])
expect
(
json_response
.
first
[
'labels'
]).
to
match_array
([
label
.
title
,
label_b
.
title
,
label_c
.
title
])
end
it
'returns an array of labeled epics when all labels matches with labels param as array'
do
label_b
=
create
(
:group_label
,
title:
'foo'
,
group:
group
)
label_c
=
create
(
:label
,
title:
'bar'
,
project:
project
)
create
(
:label_link
,
label:
label_b
,
target:
epic2
)
create
(
:label_link
,
label:
label_c
,
target:
epic2
)
get
api
(
url
,
user
),
params:
{
labels:
[
label
.
title
,
label_b
.
title
,
label_c
.
title
]
}
expect_paginated_array_response
([
epic2
.
id
])
expect
(
json_response
.
first
[
'labels'
]).
to
match_array
([
label
.
title
,
label_b
.
title
,
label_c
.
title
])
end
it
'returns an empty array if no epic matches labels'
do
get
api
(
url
,
user
),
params:
{
labels:
'foo,bar'
}
expect_paginated_array_response
([])
end
it
'returns an empty array if no epic matches labels with labels param as array'
do
get
api
(
url
,
user
),
params:
{
labels:
%w(foo bar)
}
expect_paginated_array_response
([])
end
it
'returns an array of labeled epics matching given state'
do
get
api
(
url
,
user
),
params:
{
labels:
label
.
title
,
state: :opened
}
expect_paginated_array_response
(
epic2
.
id
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
expect
(
json_response
.
first
[
'state'
]).
to
eq
(
'opened'
)
end
it
'returns an array of labeled epics matching given state with labels param as array'
do
get
api
(
url
,
user
),
params:
{
labels:
[
label
.
title
],
state: :opened
}
expect_paginated_array_response
(
epic2
.
id
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
expect
(
json_response
.
first
[
'state'
]).
to
eq
(
'opened'
)
end
it
'returns an empty array if no epic matches labels and state filters'
do
get
api
(
url
,
user
),
params:
{
labels:
label
.
title
,
state: :closed
}
expect_paginated_array_response
([])
end
it
'returns an array of epics with any label'
do
get
api
(
url
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
expect_paginated_array_response
(
epic2
.
id
)
end
it
'returns an array of epics with any label with labels param as array'
do
get
api
(
url
,
user
),
params:
{
labels:
[
IssuesFinder
::
FILTER_ANY
]
}
expect_paginated_array_response
(
epic2
.
id
)
end
it
'returns an array of epics with no label'
do
get
api
(
url
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_NONE
}
expect_paginated_array_response
(
epic
.
id
)
end
it
'returns an array of epics with no label with labels param as array'
do
get
api
(
url
,
user
),
params:
{
labels:
[
IssuesFinder
::
FILTER_NONE
]
}
expect_paginated_array_response
(
epic
.
id
)
end
it
'returns an array of epics with no label when using the legacy No+Label filter'
do
get
api
(
url
,
user
),
params:
{
labels:
'No Label'
}
expect_paginated_array_response
(
epic
.
id
)
end
it
'returns an array of epics with no label when using the legacy No+Label filter with labels param as array'
do
get
api
(
url
,
user
),
params:
{
labels:
[
'No Label'
]
}
expect_paginated_array_response
(
epic
.
id
)
end
it_behaves_like
'can admin epics'
end
...
...
@@ -285,12 +387,11 @@ describe API::Epics do
context
'when epics feature is enabled'
do
before
do
stub_licensed_features
(
epics:
true
)
group
.
add_developer
(
user
)
end
context
'when required parameter is missing'
do
it
'returns 400'
do
group
.
add_developer
(
user
)
post
api
(
url
,
user
),
params:
{
description:
'epic description'
}
expect
(
response
).
to
have_gitlab_http_status
(
400
)
...
...
@@ -299,8 +400,6 @@ describe API::Epics do
context
'when the request is correct'
do
before
do
group
.
add_developer
(
user
)
post
api
(
url
,
user
),
params:
params
end
...
...
@@ -337,6 +436,22 @@ describe API::Epics do
end
end
end
it
'creates a new epic with labels param as array'
do
params
[
:labels
]
=
[
'label1'
,
'label2'
,
'foo, bar'
,
'&,?'
]
post
api
(
url
,
user
),
params:
params
expect
(
response
.
status
).
to
eq
(
201
)
expect
(
json_response
[
'title'
]).
to
include
'new epic'
expect
(
json_response
[
'description'
]).
to
include
'epic description'
expect
(
json_response
[
'labels'
]).
to
include
'label1'
expect
(
json_response
[
'labels'
]).
to
include
'label2'
expect
(
json_response
[
'labels'
]).
to
include
'foo'
expect
(
json_response
[
'labels'
]).
to
include
'bar'
expect
(
json_response
[
'labels'
]).
to
include
'&'
expect
(
json_response
[
'labels'
]).
to
include
'?'
end
end
end
...
...
@@ -409,6 +524,22 @@ describe API::Epics do
end
end
it
'updates the epic with labels param as array'
do
params
[
:labels
]
=
[
'label1'
,
'label2'
,
'foo, bar'
,
'&,?'
]
put
api
(
url
,
user
),
params:
params
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'title'
]).
to
include
'new title'
expect
(
json_response
[
'description'
]).
to
include
'new description'
expect
(
json_response
[
'labels'
]).
to
include
'label1'
expect
(
json_response
[
'labels'
]).
to
include
'label2'
expect
(
json_response
[
'labels'
]).
to
include
'foo'
expect
(
json_response
[
'labels'
]).
to
include
'bar'
expect
(
json_response
[
'labels'
]).
to
include
'&'
expect
(
json_response
[
'labels'
]).
to
include
'?'
end
context
'when state_event is close'
do
it
'allows epic to be closed'
do
put
api
(
url
,
user
),
params:
{
state_event:
'close'
}
...
...
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