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
e0139d61
Commit
e0139d61
authored
Jul 31, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for issue status count resolver
- Need to fix all count to be scoped
parent
227d2967
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
122 additions
and
5 deletions
+122
-5
app/graphql/resolvers/issue_resolver_fields.rb
app/graphql/resolvers/issue_resolver_fields.rb
+0
-5
app/graphql/resolvers/issues_resolver.rb
app/graphql/resolvers/issues_resolver.rb
+5
-0
spec/graphql/resolvers/issue_status_count_resolver_spec.rb
spec/graphql/resolvers/issue_status_count_resolver_spec.rb
+24
-0
spec/graphql/types/issue_status_count_type_spec.rb
spec/graphql/types/issue_status_count_type_spec.rb
+18
-0
spec/graphql/types/project_type_spec.rb
spec/graphql/types/project_type_spec.rb
+1
-0
spec/lib/gitlab/issuables_count_for_state_spec.rb
spec/lib/gitlab/issuables_count_for_state_spec.rb
+15
-0
spec/requests/api/graphql/issue_status_counts_spec.rb
spec/requests/api/graphql/issue_status_counts_spec.rb
+59
-0
No files found.
app/graphql/resolvers/issue_resolver_fields.rb
View file @
e0139d61
...
...
@@ -8,7 +8,6 @@ module Resolvers
argument
:iid
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'IID of the issue. For example, "1"'
argument
:iids
,
[
GraphQL
::
STRING_TYPE
],
required:
false
,
description:
'List of IIDs of issues. For example, [1, 2]'
...
...
@@ -48,10 +47,6 @@ module Resolvers
argument
:search
,
GraphQL
::
STRING_TYPE
,
required:
false
,
description:
'Search query for issue title or description'
argument
:sort
,
Types
::
IssueSortEnum
,
description:
'Sort issues by this criteria'
,
required:
false
,
default_value:
'created_desc'
argument
:types
,
[
Types
::
IssueTypeEnum
],
as: :issue_types
,
description:
'Filter issues by the given issue types'
,
...
...
app/graphql/resolvers/issues_resolver.rb
View file @
e0139d61
...
...
@@ -4,6 +4,11 @@ module Resolvers
class
IssuesResolver
<
BaseResolver
prepend
Resolvers
::
IssueResolverFields
argument
:sort
,
Types
::
IssueSortEnum
,
description:
'Sort issues by this criteria'
,
required:
false
,
default_value:
'created_desc'
type
Types
::
IssueType
,
null:
true
NON_STABLE_CURSOR_SORTS
=
%i[priority_asc priority_desc
...
...
spec/graphql/resolvers/issue_status_count_resolver_spec.rb
0 → 100644
View file @
e0139d61
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Resolvers
::
IssueStatusCountsResolver
do
include
GraphqlHelpers
describe
'#resolve'
do
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:args
)
{
{}
}
subject
{
resolve_issue_status_counts
(
args
)
}
it
{
is_expected
.
to
be_a
(
Gitlab
::
IssuablesCountForState
)
}
specify
{
expect
(
subject
.
project
).
to
eq
(
project
)
}
private
def
resolve_issue_status_counts
(
args
=
{},
context
=
{
current_user:
current_user
})
resolve
(
described_class
,
obj:
project
,
args:
args
,
ctx:
context
)
end
end
end
spec/graphql/types/issue_status_count_type_spec.rb
0 → 100644
View file @
e0139d61
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
GitlabSchema
.
types
[
'IssueStatusCountsType'
]
do
specify
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'IssueStatusCountsType'
)
}
it
'exposes the expected fields'
do
expected_fields
=
%i[
all
opened
closed
merged
]
expect
(
described_class
).
to
have_graphql_fields
(
*
expected_fields
)
end
end
spec/graphql/types/project_type_spec.rb
View file @
e0139d61
...
...
@@ -27,6 +27,7 @@ RSpec.describe GitlabSchema.types['Project'] do
boards jira_import_status jira_imports services releases release
alert_management_alerts alert_management_alert alert_management_alert_status_counts
container_expiration_policy sast_ci_configuration service_desk_enabled service_desk_address
issue_status_counts
]
expect
(
described_class
).
to
include_graphql_fields
(
*
expected_fields
)
...
...
spec/lib/gitlab/issuables_count_for_state_spec.rb
View file @
e0139d61
...
...
@@ -9,6 +9,21 @@ RSpec.describe Gitlab::IssuablesCountForState do
let
(
:counter
)
{
described_class
.
new
(
finder
)
}
describe
'project given'
do
let
(
:project
)
{
build
(
:project
)
}
let
(
:counter
)
{
described_class
.
new
(
finder
,
project
)
}
it
'provides the project'
do
expect
(
counter
.
project
).
to
eq
(
project
)
end
end
describe
'.declarative_policy_class'
do
subject
{
described_class
.
declarative_policy_class
}
it
{
is_expected
.
to
eq
(
'IssuablePolicy'
)
}
end
describe
'#for_state_or_opened'
do
it
'returns the number of issuables for the given state'
do
expect
(
counter
.
for_state_or_opened
(
:closed
)).
to
eq
(
1
)
...
...
spec/requests/api/graphql/issue_status_counts_spec.rb
0 → 100644
View file @
e0139d61
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'getting Issue counts by status'
do
include
GraphqlHelpers
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:current_user
)
{
create
(
:user
)
}
let_it_be
(
:issue_opened
)
{
create
(
:issue
,
project:
project
)
}
let_it_be
(
:issue_closed
)
{
create
(
:issue
,
:closed
,
project:
project
)
}
# let_it_be(:other_project_issue) { create(:issue) }
let
(
:params
)
{
{
}
}
let
(
:fields
)
do
<<~
QUERY
#{
all_graphql_fields_for
(
'IssueStatusCountsType'
.
classify
)
}
QUERY
end
let
(
:query
)
do
graphql_query_for
(
'project'
,
{
'fullPath'
=>
project
.
full_path
},
query_graphql_field
(
'issueStatusCounts'
,
params
,
fields
)
)
end
context
'with issue count data'
do
let
(
:issue_counts
)
{
graphql_data
.
dig
(
'project'
,
'issueStatusCounts'
)
}
context
'without project permissions'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
it
{
expect
(
issue_counts
).
to
be
nil
}
end
context
'with project permissions'
do
before
do
project
.
add_developer
(
current_user
)
post_graphql
(
query
,
current_user:
current_user
)
end
it_behaves_like
'a working graphql query'
it
'returns the correct counts for each status'
do
expect
(
issue_counts
).
to
eq
(
'all'
=>
3
,
'opened'
=>
1
,
'closed'
=>
1
,
'merged'
=>
0
# merged is not relevant for issues
)
# but is included in the issuable type
end
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