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
f216d60b
Commit
f216d60b
authored
Jan 10, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor epics/issues API specs
Refactor the epics/issues API specs to remove code duplication.
parent
a9e6ba11
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
207 deletions
+118
-207
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+111
-207
spec/support/helpers/api_helpers.rb
spec/support/helpers/api_helpers.rb
+7
-0
No files found.
spec/requests/api/issues_spec.rb
View file @
f216d60b
...
@@ -92,12 +92,10 @@ describe API::Issues do
...
@@ -92,12 +92,10 @@ describe API::Issues do
end
end
context
"when authenticated"
do
context
"when authenticated"
do
let
(
:first_issue
)
{
json_response
.
first
}
it
"returns an array of issues"
do
it
"returns an array of issues"
do
get
api
(
"/issues"
,
user
)
get
api
(
"/issues"
,
user
)
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
(
[
issue
.
id
,
closed_issue
.
id
]
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
expect
(
json_response
.
last
).
to
have_key
(
'web_url'
)
expect
(
json_response
.
last
).
to
have_key
(
'web_url'
)
end
end
...
@@ -105,23 +103,19 @@ describe API::Issues do
...
@@ -105,23 +103,19 @@ describe API::Issues do
it
'returns an array of closed issues'
do
it
'returns an array of closed issues'
do
get
api
(
'/issues'
,
user
),
params:
{
state: :closed
}
get
api
(
'/issues'
,
user
),
params:
{
state: :closed
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
closed_issue
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns an array of opened issues'
do
it
'returns an array of opened issues'
do
get
api
(
'/issues'
,
user
),
params:
{
state: :opened
}
get
api
(
'/issues'
,
user
),
params:
{
state: :opened
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
it
'returns an array of all issues'
do
it
'returns an array of all issues'
do
get
api
(
'/issues'
,
user
),
params:
{
state: :all
}
get
api
(
'/issues'
,
user
),
params:
{
state: :all
}
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect
(
first_issue
[
'id'
]).
to
eq
(
issue
.
id
)
expect
(
json_response
.
second
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns issues assigned to me'
do
it
'returns issues assigned to me'
do
...
@@ -129,8 +123,7 @@ describe API::Issues do
...
@@ -129,8 +123,7 @@ describe API::Issues do
get
api
(
'/issues'
,
user2
),
params:
{
scope:
'assigned_to_me'
}
get
api
(
'/issues'
,
user2
),
params:
{
scope:
'assigned_to_me'
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues assigned to me (kebab-case)'
do
it
'returns issues assigned to me (kebab-case)'
do
...
@@ -138,8 +131,7 @@ describe API::Issues do
...
@@ -138,8 +131,7 @@ describe API::Issues do
get
api
(
'/issues'
,
user2
),
params:
{
scope:
'assigned-to-me'
}
get
api
(
'/issues'
,
user2
),
params:
{
scope:
'assigned-to-me'
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues authored by the given author id'
do
it
'returns issues authored by the given author id'
do
...
@@ -147,8 +139,7 @@ describe API::Issues do
...
@@ -147,8 +139,7 @@ describe API::Issues do
get
api
(
'/issues'
,
user
),
params:
{
author_id:
user2
.
id
,
scope:
'all'
}
get
api
(
'/issues'
,
user
),
params:
{
author_id:
user2
.
id
,
scope:
'all'
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues assigned to the given assignee id'
do
it
'returns issues assigned to the given assignee id'
do
...
@@ -156,8 +147,7 @@ describe API::Issues do
...
@@ -156,8 +147,7 @@ describe API::Issues do
get
api
(
'/issues'
,
user
),
params:
{
assignee_id:
user2
.
id
,
scope:
'all'
}
get
api
(
'/issues'
,
user
),
params:
{
assignee_id:
user2
.
id
,
scope:
'all'
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues authored by the given author id and assigned to the given assignee id'
do
it
'returns issues authored by the given author id and assigned to the given assignee id'
do
...
@@ -165,8 +155,7 @@ describe API::Issues do
...
@@ -165,8 +155,7 @@ describe API::Issues do
get
api
(
'/issues'
,
user
),
params:
{
author_id:
user2
.
id
,
assignee_id:
user2
.
id
,
scope:
'all'
}
get
api
(
'/issues'
,
user
),
params:
{
author_id:
user2
.
id
,
assignee_id:
user2
.
id
,
scope:
'all'
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues with no assignee'
do
it
'returns issues with no assignee'
do
...
@@ -174,8 +163,7 @@ describe API::Issues do
...
@@ -174,8 +163,7 @@ describe API::Issues do
get
api
(
'/issues'
,
user
),
params:
{
assignee_id:
0
,
scope:
'all'
}
get
api
(
'/issues'
,
user
),
params:
{
assignee_id:
0
,
scope:
'all'
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues with no assignee'
do
it
'returns issues with no assignee'
do
...
@@ -183,8 +171,7 @@ describe API::Issues do
...
@@ -183,8 +171,7 @@ describe API::Issues do
get
api
(
'/issues'
,
user
),
params:
{
assignee_id:
'None'
,
scope:
'all'
}
get
api
(
'/issues'
,
user
),
params:
{
assignee_id:
'None'
,
scope:
'all'
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues with any assignee'
do
it
'returns issues with any assignee'
do
...
@@ -193,18 +180,17 @@ describe API::Issues do
...
@@ -193,18 +180,17 @@ describe API::Issues do
get
api
(
'/issues'
,
user
),
params:
{
assignee_id:
'Any'
,
scope:
'all'
}
get
api
(
'/issues'
,
user
),
params:
{
assignee_id:
'Any'
,
scope:
'all'
}
expect_paginated_array_response
(
size:
3
)
expect_paginated_array_response
(
[
issue
.
id
,
confidential_issue
.
id
,
closed_issue
.
id
]
)
end
end
it
'returns issues reacted by the authenticated user'
do
it
'returns issues reacted by the authenticated user'
do
issue2
=
create
(
:issue
,
project:
project
,
author:
user
,
assignees:
[
user
])
issue2
=
create
(
:issue
,
project:
project
,
author:
user
,
assignees:
[
user
])
create
(
:award_emoji
,
awardable:
issue2
,
user:
user2
,
name:
'star'
)
create
(
:award_emoji
,
awardable:
issue2
,
user:
user2
,
name:
'star'
)
create
(
:award_emoji
,
awardable:
issue
,
user:
user2
,
name:
'thumbsup'
)
create
(
:award_emoji
,
awardable:
issue
,
user:
user2
,
name:
'thumbsup'
)
get
api
(
'/issues'
,
user2
),
params:
{
my_reaction_emoji:
'Any'
,
scope:
'all'
}
get
api
(
'/issues'
,
user2
),
params:
{
my_reaction_emoji:
'Any'
,
scope:
'all'
}
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
(
[
issue2
.
id
,
issue
.
id
]
)
end
end
it
'returns issues not reacted by the authenticated user'
do
it
'returns issues not reacted by the authenticated user'
do
...
@@ -213,21 +199,19 @@ describe API::Issues do
...
@@ -213,21 +199,19 @@ describe API::Issues do
get
api
(
'/issues'
,
user2
),
params:
{
my_reaction_emoji:
'None'
,
scope:
'all'
}
get
api
(
'/issues'
,
user2
),
params:
{
my_reaction_emoji:
'None'
,
scope:
'all'
}
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
(
[
issue
.
id
,
closed_issue
.
id
]
)
end
end
it
'returns issues matching given search string for title'
do
it
'returns issues matching given search string for title'
do
get
api
(
"/issues"
,
user
),
params:
{
search:
issue
.
title
}
get
api
(
"/issues"
,
user
),
params:
{
search:
issue
.
title
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
it
'returns issues matching given search string for description'
do
it
'returns issues matching given search string for description'
do
get
api
(
"/issues"
,
user
),
params:
{
search:
issue
.
description
}
get
api
(
"/issues"
,
user
),
params:
{
search:
issue
.
description
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
context
'filtering before a specific date'
do
context
'filtering before a specific date'
do
...
@@ -236,15 +220,13 @@ describe API::Issues do
...
@@ -236,15 +220,13 @@ describe API::Issues do
it
'returns issues created before a specific date'
do
it
'returns issues created before a specific date'
do
get
api
(
'/issues?created_before=2000-01-02T00:00:00.060Z'
,
user
)
get
api
(
'/issues?created_before=2000-01-02T00:00:00.060Z'
,
user
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues updated before a specific date'
do
it
'returns issues updated before a specific date'
do
get
api
(
'/issues?updated_before=2000-01-02T00:00:00.060Z'
,
user
)
get
api
(
'/issues?updated_before=2000-01-02T00:00:00.060Z'
,
user
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
end
end
...
@@ -254,23 +236,21 @@ describe API::Issues do
...
@@ -254,23 +236,21 @@ describe API::Issues do
it
'returns issues created after a specific date'
do
it
'returns issues created after a specific date'
do
get
api
(
"/issues?created_after=
#{
issue2
.
created_at
}
"
,
user
)
get
api
(
"/issues?created_after=
#{
issue2
.
created_at
}
"
,
user
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
it
'returns issues updated after a specific date'
do
it
'returns issues updated after a specific date'
do
get
api
(
"/issues?updated_after=
#{
issue2
.
updated_at
}
"
,
user
)
get
api
(
"/issues?updated_after=
#{
issue2
.
updated_at
}
"
,
user
)
expect
(
json_response
.
size
).
to
eq
(
1
)
expect_paginated_array_response
(
issue2
.
id
)
expect
(
first_issue
[
'id'
]).
to
eq
(
issue2
.
id
)
end
end
end
end
it
'returns an array of labeled issues'
do
it
'returns an array of labeled issues'
do
get
api
(
"/issues"
,
user
),
params:
{
labels:
label
.
title
}
get
api
(
"/issues"
,
user
),
params:
{
labels:
label
.
title
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
first_issue
[
'labels'
]).
to
eq
([
label
.
title
])
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
end
end
it
'returns an array of labeled issues when all labels matches'
do
it
'returns an array of labeled issues when all labels matches'
do
...
@@ -282,20 +262,20 @@ describe API::Issues do
...
@@ -282,20 +262,20 @@ describe API::Issues do
get
api
(
"/issues"
,
user
),
params:
{
labels:
"
#{
label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
}
get
api
(
"/issues"
,
user
),
params:
{
labels:
"
#{
label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
label
.
title
])
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
label
.
title
])
end
end
it
'returns an empty array if no issue matches labels'
do
it
'returns an empty array if no issue matches labels'
do
get
api
(
'/issues'
,
user
),
params:
{
labels:
'foo,bar'
}
get
api
(
'/issues'
,
user
),
params:
{
labels:
'foo,bar'
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an array of labeled issues matching given state'
do
it
'returns an array of labeled issues matching given state'
do
get
api
(
"/issues"
,
user
),
params:
{
labels:
label
.
title
,
state: :opened
}
get
api
(
"/issues"
,
user
),
params:
{
labels:
label
.
title
,
state: :opened
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
expect
(
json_response
.
first
[
'state'
]).
to
eq
(
'opened'
)
expect
(
json_response
.
first
[
'state'
]).
to
eq
(
'opened'
)
end
end
...
@@ -303,112 +283,96 @@ describe API::Issues do
...
@@ -303,112 +283,96 @@ describe API::Issues do
it
'returns an empty array if no issue matches labels and state filters'
do
it
'returns an empty array if no issue matches labels and state filters'
do
get
api
(
"/issues"
,
user
),
params:
{
labels:
label
.
title
,
state: :closed
}
get
api
(
"/issues"
,
user
),
params:
{
labels:
label
.
title
,
state: :closed
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an array of issues with any label'
do
it
'returns an array of issues with any label'
do
get
api
(
"/issues"
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
get
api
(
"/issues"
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
it
'returns an array of issues with no label'
do
it
'returns an array of issues with no label'
do
get
api
(
"/issues"
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_NONE
}
get
api
(
"/issues"
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_NONE
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
closed_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns an array of issues with no label when using the legacy No+Label filter'
do
it
'returns an array of issues with no label when using the legacy No+Label filter'
do
get
api
(
"/issues"
,
user
),
params:
{
labels:
"No Label"
}
get
api
(
"/issues"
,
user
),
params:
{
labels:
"No Label"
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
closed_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns an empty array if no issue matches milestone'
do
it
'returns an empty array if no issue matches milestone'
do
get
api
(
"/issues?milestone=
#{
empty_milestone
.
title
}
"
,
user
)
get
api
(
"/issues?milestone=
#{
empty_milestone
.
title
}
"
,
user
)
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an empty array if milestone does not exist'
do
it
'returns an empty array if milestone does not exist'
do
get
api
(
"/issues?milestone=foo"
,
user
)
get
api
(
"/issues?milestone=foo"
,
user
)
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an array of issues in given milestone'
do
it
'returns an array of issues in given milestone'
do
get
api
(
"/issues?milestone=
#{
milestone
.
title
}
"
,
user
)
get
api
(
"/issues?milestone=
#{
milestone
.
title
}
"
,
user
)
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
expect
(
json_response
.
second
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns an array of issues matching state in milestone'
do
it
'returns an array of issues matching state in milestone'
do
get
api
(
"/issues?milestone=
#{
milestone
.
title
}
"
\
get
api
(
"/issues?milestone=
#{
milestone
.
title
}
"
\
'&state=closed'
,
user
)
'&state=closed'
,
user
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
closed_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns an array of issues with no milestone'
do
it
'returns an array of issues with no milestone'
do
get
api
(
"/issues?milestone=
#{
no_milestone_title
}
"
,
author
)
get
api
(
"/issues?milestone=
#{
no_milestone_title
}
"
,
author
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
confidential_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
confidential_issue
.
id
)
end
end
it
'returns an array of issues found by iids'
do
it
'returns an array of issues found by iids'
do
get
api
(
'/issues'
,
user
),
params:
{
iids:
[
closed_issue
.
iid
]
}
get
api
(
'/issues'
,
user
),
params:
{
iids:
[
closed_issue
.
iid
]
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
closed_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns an empty array if iid does not exist'
do
it
'returns an empty array if iid does not exist'
do
get
api
(
"/issues"
,
user
),
params:
{
iids:
[
99999
]
}
get
api
(
"/issues"
,
user
),
params:
{
iids:
[
99999
]
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'sorts by created_at descending by default'
do
it
'sorts by created_at descending by default'
do
get
api
(
'/issues'
,
user
)
get
api
(
'/issues'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect_paginated_array_response
(
size:
2
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
end
it
'sorts ascending when requested'
do
it
'sorts ascending when requested'
do
get
api
(
'/issues?sort=asc'
,
user
)
get
api
(
'/issues?sort=asc'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect_paginated_array_response
([
closed_issue
.
id
,
issue
.
id
])
expect_paginated_array_response
(
size:
2
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
it
'sorts by updated_at descending when requested'
do
it
'sorts by updated_at descending when requested'
do
get
api
(
'/issues?order_by=updated_at'
,
user
)
get
api
(
'/issues?order_by=updated_at'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
issue
.
touch
(
:updated_at
)
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
end
it
'sorts by updated_at ascending when requested'
do
it
'sorts by updated_at ascending when requested'
do
get
api
(
'/issues?order_by=updated_at&sort=asc'
,
user
)
get
api
(
'/issues?order_by=updated_at&sort=asc'
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
issue
.
touch
(
:updated_at
)
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
([
closed_issue
.
id
,
issue
.
id
])
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
it
'matches V4 response schema'
do
it
'matches V4 response schema'
do
...
@@ -430,7 +394,8 @@ describe API::Issues do
...
@@ -430,7 +394,8 @@ describe API::Issues do
project:
group_project
,
project:
group_project
,
state: :closed
,
state: :closed
,
milestone:
group_milestone
,
milestone:
group_milestone
,
updated_at:
3
.
hours
.
ago
updated_at:
3
.
hours
.
ago
,
created_at:
1
.
day
.
ago
end
end
let!
(
:group_confidential_issue
)
do
let!
(
:group_confidential_issue
)
do
create
:issue
,
create
:issue
,
...
@@ -438,7 +403,8 @@ describe API::Issues do
...
@@ -438,7 +403,8 @@ describe API::Issues do
project:
group_project
,
project:
group_project
,
author:
author
,
author:
author
,
assignees:
[
assignee
],
assignees:
[
assignee
],
updated_at:
2
.
hours
.
ago
updated_at:
2
.
hours
.
ago
,
created_at:
2
.
days
.
ago
end
end
let!
(
:group_issue
)
do
let!
(
:group_issue
)
do
create
:issue
,
create
:issue
,
...
@@ -448,7 +414,8 @@ describe API::Issues do
...
@@ -448,7 +414,8 @@ describe API::Issues do
milestone:
group_milestone
,
milestone:
group_milestone
,
updated_at:
1
.
hour
.
ago
,
updated_at:
1
.
hour
.
ago
,
title:
issue_title
,
title:
issue_title
,
description:
issue_description
description:
issue_description
,
created_at:
5
.
days
.
ago
end
end
let!
(
:group_label
)
do
let!
(
:group_label
)
do
create
(
:label
,
title:
'group_lbl'
,
color:
'#FFAABB'
,
project:
group_project
)
create
(
:label
,
title:
'group_lbl'
,
color:
'#FFAABB'
,
project:
group_project
)
...
@@ -479,10 +446,7 @@ describe API::Issues do
...
@@ -479,10 +446,7 @@ describe API::Issues do
it
'also returns subgroups projects issues'
do
it
'also returns subgroups projects issues'
do
get
api
(
base_url
,
user
)
get
api
(
base_url
,
user
)
issue_ids
=
json_response
.
map
{
|
issue
|
issue
[
'id'
]
}
expect_paginated_array_response
([
issue_2
.
id
,
issue_1
.
id
,
group_closed_issue
.
id
,
group_confidential_issue
.
id
,
group_issue
.
id
])
expect_paginated_array_response
(
size:
5
)
expect
(
issue_ids
).
to
include
(
issue_1
.
id
,
issue_2
.
id
)
end
end
end
end
...
@@ -490,7 +454,7 @@ describe API::Issues do
...
@@ -490,7 +454,7 @@ describe API::Issues do
it
'lists all issues in public projects'
do
it
'lists all issues in public projects'
do
get
api
(
base_url
)
get
api
(
base_url
)
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
(
[
group_closed_issue
.
id
,
group_issue
.
id
]
)
end
end
end
end
...
@@ -502,65 +466,62 @@ describe API::Issues do
...
@@ -502,65 +466,62 @@ describe API::Issues do
it
'returns all group issues (including opened and closed)'
do
it
'returns all group issues (including opened and closed)'
do
get
api
(
base_url
,
admin
)
get
api
(
base_url
,
admin
)
expect_paginated_array_response
(
size:
3
)
expect_paginated_array_response
(
[
group_closed_issue
.
id
,
group_confidential_issue
.
id
,
group_issue
.
id
]
)
end
end
it
'returns group issues without confidential issues for non project members'
do
it
'returns group issues without confidential issues for non project members'
do
get
api
(
base_url
,
non_member
),
params:
{
state: :opened
}
get
api
(
base_url
,
non_member
),
params:
{
state: :opened
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
group_issue
.
title
)
end
end
it
'returns group confidential issues for author'
do
it
'returns group confidential issues for author'
do
get
api
(
base_url
,
author
),
params:
{
state: :opened
}
get
api
(
base_url
,
author
),
params:
{
state: :opened
}
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
(
[
group_confidential_issue
.
id
,
group_issue
.
id
]
)
end
end
it
'returns group confidential issues for assignee'
do
it
'returns group confidential issues for assignee'
do
get
api
(
base_url
,
assignee
),
params:
{
state: :opened
}
get
api
(
base_url
,
assignee
),
params:
{
state: :opened
}
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
(
[
group_confidential_issue
.
id
,
group_issue
.
id
]
)
end
end
it
'returns group issues with confidential issues for project members'
do
it
'returns group issues with confidential issues for project members'
do
get
api
(
base_url
,
user
),
params:
{
state: :opened
}
get
api
(
base_url
,
user
),
params:
{
state: :opened
}
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
(
[
group_confidential_issue
.
id
,
group_issue
.
id
]
)
end
end
it
'returns group confidential issues for admin'
do
it
'returns group confidential issues for admin'
do
get
api
(
base_url
,
admin
),
params:
{
state: :opened
}
get
api
(
base_url
,
admin
),
params:
{
state: :opened
}
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
(
[
group_confidential_issue
.
id
,
group_issue
.
id
]
)
end
end
it
'returns an array of labeled group issues'
do
it
'returns an array of labeled group issues'
do
get
api
(
base_url
,
user
),
params:
{
labels:
group_label
.
title
}
get
api
(
base_url
,
user
),
params:
{
labels:
group_label
.
title
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
group_label
.
title
])
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
group_label
.
title
])
end
end
it
'returns an array of labeled group issues where all labels match'
do
it
'returns an array of labeled group issues where all labels match'
do
get
api
(
base_url
,
user
),
params:
{
labels:
"
#{
group_label
.
title
}
,foo,bar"
}
get
api
(
base_url
,
user
),
params:
{
labels:
"
#{
group_label
.
title
}
,foo,bar"
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns issues matching given search string for title'
do
it
'returns issues matching given search string for title'
do
get
api
(
base_url
,
user
),
params:
{
search:
group_issue
.
title
}
get
api
(
base_url
,
user
),
params:
{
search:
group_issue
.
title
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
end
end
it
'returns issues matching given search string for description'
do
it
'returns issues matching given search string for description'
do
get
api
(
base_url
,
user
),
params:
{
search:
group_issue
.
description
}
get
api
(
base_url
,
user
),
params:
{
search:
group_issue
.
description
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
end
end
it
'returns an array of labeled issues when all labels matches'
do
it
'returns an array of labeled issues when all labels matches'
do
...
@@ -572,69 +533,64 @@ describe API::Issues do
...
@@ -572,69 +533,64 @@ describe API::Issues do
get
api
(
base_url
,
user
),
params:
{
labels:
"
#{
group_label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
}
get
api
(
base_url
,
user
),
params:
{
labels:
"
#{
group_label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
group_label
.
title
])
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
group_label
.
title
])
end
end
it
'returns an array of issues found by iids'
do
it
'returns an array of issues found by iids'
do
get
api
(
base_url
,
user
),
params:
{
iids:
[
group_issue
.
iid
]
}
get
api
(
base_url
,
user
),
params:
{
iids:
[
group_issue
.
iid
]
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
end
end
it
'returns an empty array if iid does not exist'
do
it
'returns an empty array if iid does not exist'
do
get
api
(
base_url
,
user
),
params:
{
iids:
[
99999
]
}
get
api
(
base_url
,
user
),
params:
{
iids:
[
99999
]
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an empty array if no group issue matches labels'
do
it
'returns an empty array if no group issue matches labels'
do
get
api
(
base_url
,
user
),
params:
{
labels:
'foo,bar'
}
get
api
(
base_url
,
user
),
params:
{
labels:
'foo,bar'
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an array of group issues with any label'
do
it
'returns an array of group issues with any label'
do
get
api
(
base_url
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
get
api
(
base_url
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
end
end
it
'returns an array of group issues with no label'
do
it
'returns an array of group issues with no label'
do
get
api
(
base_url
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_NONE
}
get
api
(
base_url
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_NONE
}
response_ids
=
json_response
.
map
{
|
issue
|
issue
[
'id'
]
}
expect_paginated_array_response
([
group_closed_issue
.
id
,
group_confidential_issue
.
id
])
expect_paginated_array_response
(
size:
2
)
expect
(
response_ids
).
to
contain_exactly
(
group_closed_issue
.
id
,
group_confidential_issue
.
id
)
end
end
it
'returns an empty array if no issue matches milestone'
do
it
'returns an empty array if no issue matches milestone'
do
get
api
(
base_url
,
user
),
params:
{
milestone:
group_empty_milestone
.
title
}
get
api
(
base_url
,
user
),
params:
{
milestone:
group_empty_milestone
.
title
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an empty array if milestone does not exist'
do
it
'returns an empty array if milestone does not exist'
do
get
api
(
base_url
,
user
),
params:
{
milestone:
'foo'
}
get
api
(
base_url
,
user
),
params:
{
milestone:
'foo'
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an array of issues in given milestone'
do
it
'returns an array of issues in given milestone'
do
get
api
(
base_url
,
user
),
params:
{
state: :opened
,
milestone:
group_milestone
.
title
}
get
api
(
base_url
,
user
),
params:
{
state: :opened
,
milestone:
group_milestone
.
title
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_issue
.
id
)
end
end
it
'returns an array of issues matching state in milestone'
do
it
'returns an array of issues matching state in milestone'
do
get
api
(
base_url
,
user
),
params:
{
milestone:
group_milestone
.
title
,
state: :closed
}
get
api
(
base_url
,
user
),
params:
{
milestone:
group_milestone
.
title
,
state: :closed
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_closed_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_closed_issue
.
id
)
end
end
it
'returns an array of issues with no milestone'
do
it
'returns an array of issues with no milestone'
do
...
@@ -642,44 +598,33 @@ describe API::Issues do
...
@@ -642,44 +598,33 @@ describe API::Issues do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
group_confidential_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
group_confidential_issue
.
id
)
end
end
it
'sorts by created_at descending by default'
do
it
'sorts by created_at descending by default'
do
get
api
(
base_url
,
user
)
get
api
(
base_url
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect_paginated_array_response
([
group_closed_issue
.
id
,
group_confidential_issue
.
id
,
group_issue
.
id
])
expect_paginated_array_response
(
size:
3
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
end
it
'sorts ascending when requested'
do
it
'sorts ascending when requested'
do
get
api
(
"
#{
base_url
}
?sort=asc"
,
user
)
get
api
(
"
#{
base_url
}
?sort=asc"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect_paginated_array_response
([
group_issue
.
id
,
group_confidential_issue
.
id
,
group_closed_issue
.
id
])
expect_paginated_array_response
(
size:
3
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
it
'sorts by updated_at descending when requested'
do
it
'sorts by updated_at descending when requested'
do
get
api
(
"
#{
base_url
}
?order_by=updated_at"
,
user
)
get
api
(
"
#{
base_url
}
?order_by=updated_at"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
group_issue
.
touch
(
:updated_at
)
expect_paginated_array_response
(
size:
3
)
expect_paginated_array_response
([
group_issue
.
id
,
group_confidential_issue
.
id
,
group_closed_issue
.
id
])
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
end
it
'sorts by updated_at ascending when requested'
do
it
'sorts by updated_at ascending when requested'
do
get
api
(
base_url
,
user
),
params:
{
order_by: :updated_at
,
sort: :asc
}
get
api
(
base_url
,
user
),
params:
{
order_by: :updated_at
,
sort: :asc
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect_paginated_array_response
([
group_closed_issue
.
id
,
group_confidential_issue
.
id
,
group_issue
.
id
])
expect_paginated_array_response
(
size:
3
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
end
end
end
end
...
@@ -691,8 +636,7 @@ describe API::Issues do
...
@@ -691,8 +636,7 @@ describe API::Issues do
it
'returns public project issues'
do
it
'returns public project issues'
do
get
api
(
"/projects/
#{
project
.
id
}
/issues"
)
get
api
(
"/projects/
#{
project
.
id
}
/issues"
)
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
end
end
end
end
...
@@ -731,56 +675,49 @@ describe API::Issues do
...
@@ -731,56 +675,49 @@ describe API::Issues do
get
api
(
"/projects/
#{
restricted_project
.
id
}
/issues"
,
non_member
)
get
api
(
"/projects/
#{
restricted_project
.
id
}
/issues"
,
non_member
)
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns project issues without confidential issues for non project members'
do
it
'returns project issues without confidential issues for non project members'
do
get
api
(
"
#{
base_url
}
/issues"
,
non_member
)
get
api
(
"
#{
base_url
}
/issues"
,
non_member
)
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
end
end
it
'returns project issues without confidential issues for project members with guest role'
do
it
'returns project issues without confidential issues for project members with guest role'
do
get
api
(
"
#{
base_url
}
/issues"
,
guest
)
get
api
(
"
#{
base_url
}
/issues"
,
guest
)
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
end
end
it
'returns project confidential issues for author'
do
it
'returns project confidential issues for author'
do
get
api
(
"
#{
base_url
}
/issues"
,
author
)
get
api
(
"
#{
base_url
}
/issues"
,
author
)
expect_paginated_array_response
(
size:
3
)
expect_paginated_array_response
([
issue
.
id
,
confidential_issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
end
end
it
'returns project confidential issues for assignee'
do
it
'returns project confidential issues for assignee'
do
get
api
(
"
#{
base_url
}
/issues"
,
assignee
)
get
api
(
"
#{
base_url
}
/issues"
,
assignee
)
expect_paginated_array_response
(
size:
3
)
expect_paginated_array_response
([
issue
.
id
,
confidential_issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
end
end
it
'returns project issues with confidential issues for project members'
do
it
'returns project issues with confidential issues for project members'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
)
get
api
(
"
#{
base_url
}
/issues"
,
user
)
expect_paginated_array_response
(
size:
3
)
expect_paginated_array_response
([
issue
.
id
,
confidential_issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
end
end
it
'returns project confidential issues for admin'
do
it
'returns project confidential issues for admin'
do
get
api
(
"
#{
base_url
}
/issues"
,
admin
)
get
api
(
"
#{
base_url
}
/issues"
,
admin
)
expect_paginated_array_response
(
size:
3
)
expect_paginated_array_response
([
issue
.
id
,
confidential_issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'title'
]).
to
eq
(
issue
.
title
)
end
end
it
'returns an array of labeled project issues'
do
it
'returns an array of labeled project issues'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
label
.
title
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
label
.
title
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label
.
title
])
end
end
it
'returns an array of labeled issues when all labels matches'
do
it
'returns an array of labeled issues when all labels matches'
do
...
@@ -792,142 +729,117 @@ describe API::Issues do
...
@@ -792,142 +729,117 @@ describe API::Issues do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
"
#{
label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
"
#{
label
.
title
}
,
#{
label_b
.
title
}
,
#{
label_c
.
title
}
"
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'labels'
]).
to
eq
([
label_c
.
title
,
label_b
.
title
,
label
.
title
])
end
end
it
'returns issues matching given search string for title'
do
it
'returns issues matching given search string for title'
do
get
api
(
"
#{
base_url
}
/issues?search=
#{
issue
.
title
}
"
,
user
)
get
api
(
"
#{
base_url
}
/issues?search=
#{
issue
.
title
}
"
,
user
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
it
'returns issues matching given search string for description'
do
it
'returns issues matching given search string for description'
do
get
api
(
"
#{
base_url
}
/issues?search=
#{
issue
.
description
}
"
,
user
)
get
api
(
"
#{
base_url
}
/issues?search=
#{
issue
.
description
}
"
,
user
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
it
'returns an array of issues found by iids'
do
it
'returns an array of issues found by iids'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
iids:
[
issue
.
iid
]
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
iids:
[
issue
.
iid
]
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
it
'returns an empty array if iid does not exist'
do
it
'returns an empty array if iid does not exist'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
iids:
[
99999
]
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
iids:
[
99999
]
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an empty array if not all labels matches'
do
it
'returns an empty array if not all labels matches'
do
get
api
(
"
#{
base_url
}
/issues?labels=
#{
label
.
title
}
,foo"
,
user
)
get
api
(
"
#{
base_url
}
/issues?labels=
#{
label
.
title
}
,foo"
,
user
)
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an array of project issues with any label'
do
it
'returns an array of project issues with any label'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_ANY
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
end
end
it
'returns an array of project issues with no label'
do
it
'returns an array of project issues with no label'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_NONE
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
IssuesFinder
::
FILTER_NONE
}
response_ids
=
json_response
.
map
{
|
issue
|
issue
[
'id'
]
}
expect_paginated_array_response
([
confidential_issue
.
id
,
closed_issue
.
id
])
expect_paginated_array_response
(
size:
2
)
expect
(
response_ids
).
to
contain_exactly
(
closed_issue
.
id
,
confidential_issue
.
id
)
end
end
it
'returns an empty array if no project issue matches labels'
do
it
'returns an empty array if no project issue matches labels'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
'foo,bar'
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
labels:
'foo,bar'
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an empty array if no issue matches milestone'
do
it
'returns an empty array if no issue matches milestone'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
empty_milestone
.
title
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
empty_milestone
.
title
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an empty array if milestone does not exist'
do
it
'returns an empty array if milestone does not exist'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone: :foo
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone: :foo
}
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
it
'returns an array of issues in given milestone'
do
it
'returns an array of issues in given milestone'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
milestone
.
title
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
milestone
.
title
}
expect_paginated_array_response
(
size:
2
)
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
issue
.
id
)
expect
(
json_response
.
second
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns an array of issues matching state in milestone'
do
it
'returns an array of issues matching state in milestone'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
milestone
.
title
,
state: :closed
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
milestone
.
title
,
state: :closed
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
closed_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
closed_issue
.
id
)
end
end
it
'returns an array of issues with no milestone'
do
it
'returns an array of issues with no milestone'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
no_milestone_title
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
no_milestone_title
}
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
confidential_issue
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
confidential_issue
.
id
)
end
end
it
'returns an array of issues with any milestone'
do
it
'returns an array of issues with any milestone'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
any_milestone_title
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
milestone:
any_milestone_title
}
response_ids
=
json_response
.
map
{
|
issue
|
issue
[
'id'
]
}
expect_paginated_array_response
([
issue
.
id
,
closed_issue
.
id
])
expect_paginated_array_response
(
size:
2
)
expect
(
response_ids
).
to
contain_exactly
(
closed_issue
.
id
,
issue
.
id
)
end
end
it
'sorts by created_at descending by default'
do
it
'sorts by created_at descending by default'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
)
get
api
(
"
#{
base_url
}
/issues"
,
user
)
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect_paginated_array_response
([
issue
.
id
,
confidential_issue
.
id
,
closed_issue
.
id
])
expect_paginated_array_response
(
size:
3
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
end
it
'sorts ascending when requested'
do
it
'sorts ascending when requested'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
sort: :asc
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
sort: :asc
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'created_at'
]
}
expect_paginated_array_response
([
closed_issue
.
id
,
confidential_issue
.
id
,
issue
.
id
])
expect_paginated_array_response
(
size:
3
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
it
'sorts by updated_at descending when requested'
do
it
'sorts by updated_at descending when requested'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
order_by: :updated_at
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
order_by: :updated_at
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
issue
.
touch
(
:updated_at
)
expect_paginated_array_response
(
size:
3
)
expect_paginated_array_response
([
issue
.
id
,
confidential_issue
.
id
,
closed_issue
.
id
])
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
.
reverse
)
end
end
it
'sorts by updated_at ascending when requested'
do
it
'sorts by updated_at ascending when requested'
do
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
order_by: :updated_at
,
sort: :asc
}
get
api
(
"
#{
base_url
}
/issues"
,
user
),
params:
{
order_by: :updated_at
,
sort: :asc
}
response_dates
=
json_response
.
map
{
|
issue
|
issue
[
'updated_at'
]
}
expect_paginated_array_response
([
closed_issue
.
id
,
confidential_issue
.
id
,
issue
.
id
])
expect_paginated_array_response
(
size:
3
)
expect
(
response_dates
).
to
eq
(
response_dates
.
sort
)
end
end
end
end
...
@@ -1828,21 +1740,21 @@ describe API::Issues do
...
@@ -1828,21 +1740,21 @@ describe API::Issues do
it
'return public project issues'
do
it
'return public project issues'
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/closed_by"
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/closed_by"
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
merge_request
.
id
)
end
end
end
end
it
'returns merge requests that will close issue on merge'
do
it
'returns merge requests that will close issue on merge'
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/closed_by"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
/closed_by"
,
user
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
merge_request
.
id
)
end
end
context
'when no merge requests will close issue'
do
context
'when no merge requests will close issue'
do
it
'returns empty array'
do
it
'returns empty array'
do
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
closed_issue
.
iid
}
/closed_by"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
closed_issue
.
iid
}
/closed_by"
,
user
)
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
end
end
...
@@ -1878,7 +1790,7 @@ describe API::Issues do
...
@@ -1878,7 +1790,7 @@ describe API::Issues do
it
'return list of referenced merge requests from issue'
do
it
'return list of referenced merge requests from issue'
do
get_related_merge_requests
(
project
.
id
,
issue
.
iid
)
get_related_merge_requests
(
project
.
id
,
issue
.
iid
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
related_mr
.
id
)
end
end
it
'renders 404 if project is not visible'
do
it
'renders 404 if project is not visible'
do
...
@@ -1902,15 +1814,14 @@ describe API::Issues do
...
@@ -1902,15 +1814,14 @@ describe API::Issues do
get_related_merge_requests
(
project
.
id
,
issue
.
iid
,
user
)
get_related_merge_requests
(
project
.
id
,
issue
.
iid
,
user
)
expect_paginated_array_response
(
size:
1
)
expect_paginated_array_response
(
related_mr
.
id
)
expect
(
json_response
.
first
[
'id'
]).
to
eq
(
related_mr
.
id
)
end
end
context
'no merge request mentioned a issue'
do
context
'no merge request mentioned a issue'
do
it
'returns empty array'
do
it
'returns empty array'
do
get_related_merge_requests
(
project
.
id
,
closed_issue
.
iid
,
user
)
get_related_merge_requests
(
project
.
id
,
closed_issue
.
iid
,
user
)
expect_paginated_array_response
(
size:
0
)
expect_paginated_array_response
(
[]
)
end
end
end
end
...
@@ -1948,13 +1859,6 @@ describe API::Issues do
...
@@ -1948,13 +1859,6 @@ describe API::Issues do
end
end
end
end
def
expect_paginated_array_response
(
size:
nil
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
size
)
if
size
end
describe
'GET projects/:id/issues/:issue_iid/participants'
do
describe
'GET projects/:id/issues/:issue_iid/participants'
do
it_behaves_like
'issuable participants endpoint'
do
it_behaves_like
'issuable participants endpoint'
do
let
(
:entity
)
{
issue
}
let
(
:entity
)
{
issue
}
...
...
spec/support/helpers/api_helpers.rb
View file @
f216d60b
...
@@ -36,4 +36,11 @@ module ApiHelpers
...
@@ -36,4 +36,11 @@ module ApiHelpers
full_path
full_path
end
end
def
expect_paginated_array_response
(
items
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
map
{
|
item
|
item
[
'id'
]
}).
to
eq
(
Array
(
items
))
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