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
a8f7cfc3
Commit
a8f7cfc3
authored
Aug 26, 2020
by
Sean Arnold
Committed by
charlie ablett
Aug 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure issue status counts are scoped
Add tests to ensure this
parent
9c56c6b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
9 deletions
+45
-9
app/graphql/resolvers/issue_status_counts_resolver.rb
app/graphql/resolvers/issue_status_counts_resolver.rb
+14
-0
changelogs/unreleased/238569-fix-issuable-count-scope-graphql.yml
...gs/unreleased/238569-fix-issuable-count-scope-graphql.yml
+5
-0
spec/graphql/resolvers/issue_status_counts_resolver_spec.rb
spec/graphql/resolvers/issue_status_counts_resolver_spec.rb
+26
-9
No files found.
app/graphql/resolvers/issue_status_counts_resolver.rb
View file @
a8f7cfc3
...
...
@@ -7,7 +7,21 @@ module Resolvers
type
Types
::
IssueStatusCountsType
,
null:
true
def
continue_issue_resolve
(
parent
,
finder
,
**
args
)
finder
.
params
[
parent_param
(
parent
)]
=
parent
if
parent
apply_lookahead
(
Gitlab
::
IssuablesCountForState
.
new
(
finder
,
parent
))
end
private
def
parent_param
(
parent
)
case
parent
when
Project
:project_id
when
Group
:group_id
else
raise
"Unexpected type of parent:
#{
parent
.
class
}
. Must be Project or Group"
end
end
end
end
changelogs/unreleased/238569-fix-issuable-count-scope-graphql.yml
0 → 100644
View file @
a8f7cfc3
---
title
:
Scope incident issue counts by given project or group
merge_request
:
39914
author
:
type
:
fixed
spec/graphql/resolvers/issue_status_counts_resolver_spec.rb
View file @
a8f7cfc3
...
...
@@ -7,14 +7,21 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
describe
'#resolve'
do
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
,
state: :opened
,
created_at:
3
.
hours
.
ago
,
updated_at:
3
.
hours
.
ago
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:issue
)
{
create
(
:issue
,
project:
project
,
state: :opened
,
created_at:
3
.
hours
.
ago
,
updated_at:
3
.
hours
.
ago
)
}
let_it_be
(
:incident
)
{
create
(
:incident
,
project:
project
,
state: :closed
,
created_at:
1
.
hour
.
ago
,
updated_at:
1
.
hour
.
ago
,
closed_at:
1
.
hour
.
ago
)
}
# This issue should not be included in the counts
let_it_be
(
:other_project
)
{
create
(
:project
)
}
let_it_be
(
:other_proj_issue
)
{
create
(
:issue
,
state: :opened
,
project:
other_project
)
}
let
(
:parent
)
{
project
}
let
(
:args
)
{
{}
}
before
do
before
_all
do
project
.
add_developer
(
current_user
)
other_project
.
add_developer
(
current_user
)
end
subject
{
resolve_issue_status_counts
(
args
)
}
...
...
@@ -22,12 +29,22 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
it
{
is_expected
.
to
be_a
(
Gitlab
::
IssuablesCountForState
)
}
specify
{
expect
(
subject
.
project
).
to
eq
(
project
)
}
it
'returns expected results'
do
result
=
resolve_issue_status_counts
shared_examples
'returns expected results'
do
it
'returns expected results'
,
:aggregate_failures
do
result
=
resolve_issue_status_counts
expect
(
result
.
all
).
to
eq
2
expect
(
result
.
opened
).
to
eq
1
expect
(
result
.
closed
).
to
eq
1
expect
(
result
.
all
).
to
eq
2
expect
(
result
.
opened
).
to
eq
1
expect
(
result
.
closed
).
to
eq
1
end
end
it_behaves_like
'returns expected results'
context
'group used as parent'
do
let
(
:parent
)
{
project
.
group
}
it_behaves_like
'returns expected results'
end
it
'filters by search'
,
:aggregate_failures
do
...
...
@@ -58,7 +75,7 @@ RSpec.describe Resolvers::IssueStatusCountsResolver do
private
def
resolve_issue_status_counts
(
args
=
{},
context
=
{
current_user:
current_user
})
resolve
(
described_class
,
obj:
p
rojec
t
,
args:
args
,
ctx:
context
)
resolve
(
described_class
,
obj:
p
aren
t
,
args:
args
,
ctx:
context
)
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