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
1ec0b86c
Commit
1ec0b86c
authored
Nov 04, 2020
by
Pavel Shutsin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add epic filter to issues rest API
Will be used at issues analytics page
parent
bfb5044a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
19 deletions
+57
-19
ee/changelogs/unreleased/221044-add-epic-filter-to-issues-graphql.yml
...s/unreleased/221044-add-epic-filter-to-issues-graphql.yml
+5
-0
ee/lib/ee/api/helpers/issues_helpers.rb
ee/lib/ee/api/helpers/issues_helpers.rb
+1
-0
ee/spec/requests/api/issues_spec.rb
ee/spec/requests/api/issues_spec.rb
+51
-18
spec/support/helpers/api_helpers.rb
spec/support/helpers/api_helpers.rb
+0
-1
No files found.
ee/changelogs/unreleased/221044-add-epic-filter-to-issues-graphql.yml
0 → 100644
View file @
1ec0b86c
---
title
:
Add epic filter option to public APIs
merge_request
:
46887
author
:
type
:
added
ee/lib/ee/api/helpers/issues_helpers.rb
View file @
1ec0b86c
...
...
@@ -16,6 +16,7 @@ module EE
params
:optional_issues_params_ee
do
optional
:weight
,
types:
[
Integer
,
String
],
integer_none_any:
true
,
desc:
'The weight of the issue'
optional
:epic_id
,
types:
[
Integer
,
String
],
integer_none_any:
true
,
desc:
'The ID of an epic associated with the issues'
end
end
...
...
ee/spec/requests/api/issues_spec.rb
View file @
1ec0b86c
...
...
@@ -12,23 +12,9 @@ RSpec.describe API::Issues, :mailer do
let_it_be
(
:group_project
)
{
create
(
:project
,
:public
,
creator_id:
user
.
id
,
namespace:
group
)
}
let
(
:user2
)
{
create
(
:user
)
}
let_it_be
(
:author
)
{
create
(
:author
)
}
let_it_be
(
:assignee
)
{
create
(
:assignee
)
}
let
(
:issue_title
)
{
'foo'
}
let
(
:issue_description
)
{
'closed'
}
let!
(
:issue
)
do
create
:issue
,
author:
user
,
assignees:
[
user
],
project:
project
,
milestone:
milestone
,
created_at:
generate
(
:past_time
),
updated_at:
1
.
hour
.
ago
,
title:
issue_title
,
description:
issue_description
end
let_it_be
(
:milestone
)
{
create
(
:milestone
,
title:
'1.0.0'
,
project:
project
)
}
before_all
do
project
.
add_reporter
(
user
)
...
...
@@ -92,6 +78,36 @@ RSpec.describe API::Issues, :mailer do
end
end
shared_examples
'filtering by epic_id'
do
let_it_be
(
:epic1
)
{
create
:epic
,
group:
group_project
.
namespace
}
let_it_be
(
:epic2
)
{
create
:epic
,
group:
group_project
.
namespace
}
let_it_be
(
:issue1
)
{
create
(
:issue
,
{
author:
user
,
epic:
epic1
,
project:
group_project
})
}
let_it_be
(
:issue2
)
{
create
(
:issue
,
{
author:
user
,
epic:
epic2
,
project:
group_project
})
}
let_it_be
(
:issue3
)
{
create
(
:issue
,
{
author:
user
,
project:
group_project
})
}
before
do
stub_licensed_features
(
epics:
true
)
end
it
'returns issues without epic when epic_id is "None"'
do
get
api
(
endpoint
,
user
),
params:
{
epic_id:
'None'
,
scope:
'all'
}
expect_response_contain_exactly
(
issue3
.
id
)
end
it
'returns issues with any epic when epic_id is "Any"'
do
get
api
(
endpoint
,
user
),
params:
{
epic_id:
'Any'
,
scope:
'all'
}
expect_response_contain_exactly
(
issue1
.
id
,
issue2
.
id
)
end
it
'returns issues with any epic when epic_id is specific'
do
get
api
(
endpoint
,
user
),
params:
{
epic_id:
epic1
.
id
,
scope:
'all'
}
expect_response_contain_exactly
(
issue1
.
id
)
end
end
describe
"GET /issues"
do
context
"when authenticated"
do
it
'matches V4 response schema'
do
...
...
@@ -102,6 +118,8 @@ RSpec.describe API::Issues, :mailer do
end
context
"blocking issues count"
do
let!
(
:issue
)
{
create
:issue
,
author:
user
,
project:
project
}
it
'returns a blocking issues count of 0 if there are no blocking issues'
do
get
api
(
'/issues'
,
user
)
...
...
@@ -121,6 +139,7 @@ RSpec.describe API::Issues, :mailer do
end
context
"filtering by weight"
do
let!
(
:issue
)
{
create
(
:issue
,
author:
user2
,
project:
project
,
weight:
nil
,
created_at:
4
.
days
.
ago
)
}
let!
(
:issue1
)
{
create
(
:issue
,
author:
user2
,
project:
project
,
weight:
1
,
created_at:
3
.
days
.
ago
)
}
let!
(
:issue2
)
{
create
(
:issue
,
author:
user2
,
project:
project
,
weight:
5
,
created_at:
2
.
days
.
ago
)
}
let!
(
:issue3
)
{
create
(
:issue
,
author:
user2
,
project:
project
,
weight:
3
,
created_at:
1
.
day
.
ago
)
}
...
...
@@ -156,6 +175,10 @@ RSpec.describe API::Issues, :mailer do
expect_paginated_array_response
(
issue3
.
id
)
end
end
it_behaves_like
'filtering by epic_id'
do
let
(
:endpoint
)
{
'/issues'
}
end
end
end
...
...
@@ -180,7 +203,11 @@ RSpec.describe API::Issues, :mailer do
end
end
include_examples
'exposes epic'
do
it_behaves_like
'filtering by epic_id'
do
let
(
:endpoint
)
{
"/groups/
#{
group_project
.
group
.
id
}
/issues"
}
end
it_behaves_like
'exposes epic'
do
let!
(
:issue_with_epic
)
{
create
(
:issue
,
project:
group_project
,
epic:
epic
)
}
end
end
...
...
@@ -206,6 +233,10 @@ RSpec.describe API::Issues, :mailer do
end
end
it_behaves_like
'filtering by epic_id'
do
let
(
:endpoint
)
{
"/projects/
#{
group_project
.
id
}
/issues"
}
end
context
'on personal project'
do
let!
(
:issue_with_epic
)
{
create
(
:issue
,
project:
project
,
epic:
epic
)
}
...
...
@@ -226,7 +257,7 @@ RSpec.describe API::Issues, :mailer do
subject
{
get
api
(
"/projects/
#{
group_project
.
id
}
/issues"
,
user
)
}
i
nclude_examples
'exposes epic'
i
t_behaves_like
'exposes epic'
end
end
...
...
@@ -253,7 +284,7 @@ RSpec.describe API::Issues, :mailer do
subject
{
get
api
(
"/projects/
#{
group_project
.
id
}
/issues/
#{
issue_with_epic
.
iid
}
"
,
user
)
}
i
nclude_examples
'exposes epic'
i
t_behaves_like
'exposes epic'
end
end
...
...
@@ -368,6 +399,8 @@ RSpec.describe API::Issues, :mailer do
end
describe
'PUT /projects/:id/issues/:issue_id to update weight'
do
let!
(
:issue
)
{
create
:issue
,
author:
user
,
project:
project
}
it
'updates an issue with no weight'
do
put
api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
iid
}
"
,
user
),
params:
{
weight:
101
}
...
...
spec/support/helpers/api_helpers.rb
View file @
1ec0b86c
...
...
@@ -61,7 +61,6 @@ module ApiHelpers
def
expect_response_contain_exactly
(
*
items
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
items
.
size
)
expect
(
json_response
.
map
{
|
item
|
item
[
'id'
]
}).
to
contain_exactly
(
*
items
)
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