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
23048f87
Commit
23048f87
authored
Sep 06, 2021
by
Alexandru Croitor
Committed by
charlie ablett
Sep 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix fetch iteration cadence by id
parent
7a16c502
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
154 additions
and
2 deletions
+154
-2
ee/app/graphql/resolvers/iterations/cadences_resolver.rb
ee/app/graphql/resolvers/iterations/cadences_resolver.rb
+11
-2
ee/spec/graphql/resolvers/iterations/cadences_resolver_spec.rb
...ec/graphql/resolvers/iterations/cadences_resolver_spec.rb
+6
-0
ee/spec/requests/api/graphql/iterations/cadences_spec.rb
ee/spec/requests/api/graphql/iterations/cadences_spec.rb
+137
-0
ee/spec/requests/api/graphql/iterations/iterations_spec.rb
ee/spec/requests/api/graphql/iterations/iterations_spec.rb
+0
-0
No files found.
ee/app/graphql/resolvers/iterations/cadences_resolver.rb
View file @
23048f87
...
...
@@ -26,16 +26,25 @@ module Resolvers
type
::
Types
::
Iterations
::
CadenceType
.
connection_type
,
null:
true
def
resolve
(
**
args
)
def
resolve
(
id:
nil
,
**
args
)
authorize!
cadences
=
::
Iterations
::
CadencesFinder
.
new
(
context
[
:current_user
],
group
,
args
).
execute
args
[
:id
]
=
parse_id
(
id
)
if
id
.
present?
cadences
=
::
Iterations
::
CadencesFinder
.
new
(
current_user
,
group
,
args
).
execute
offset_pagination
(
cadences
)
end
private
def
parse_id
(
id
)
GitlabSchema
.
parse_gid
(
id
,
expected_type:
::
Iterations
::
Cadence
).
model_id
rescue
Gitlab
::
Graphql
::
Errors
::
ArgumentError
# we need to support parameter as a raw model ID, not just valid global ID.
id
end
def
group
@parent
||=
object
.
respond_to?
(
:sync
)
?
object
.
sync
:
object
...
...
ee/spec/graphql/resolvers/iterations/cadences_resolver_spec.rb
View file @
23048f87
...
...
@@ -29,6 +29,12 @@ RSpec.describe Resolvers::Iterations::CadencesResolver do
expect
(
resolve_group_iteration_cadences
).
to
contain_exactly
(
active_group_iteration_cadence
)
end
context
'iteration cadences by id'
do
it
'returns iterations cadence by global id'
do
expect
(
resolve_group_iteration_cadences
({
id:
active_group_iteration_cadence
.
to_global_id
},
parent
,
{
current_user:
current_user
})).
to
contain_exactly
(
active_group_iteration_cadence
)
end
end
context
'when iteration cadences feature is disabled'
do
before
do
stub_feature_flags
(
iteration_cadences:
false
)
...
...
ee/spec/requests/api/graphql/iterations/cadences_spec.rb
0 → 100644
View file @
23048f87
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'getting iterations'
do
include
GraphqlHelpers
let_it_be
(
:now
)
{
Time
.
now
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let_it_be
(
:iteration_cadence1
)
{
create
(
:iterations_cadence
,
group:
group
,
active:
true
,
duration_in_weeks:
1
,
title:
'one week iterations'
)
}
let_it_be
(
:iteration_cadence2
)
{
create
(
:iterations_cadence
,
group:
group
,
active:
true
,
duration_in_weeks:
2
,
title:
'two week iterations'
)
}
before
do
group
.
add_developer
(
user
)
end
describe
'query for iteration cadence'
do
shared_examples
'returns cadence by id'
do
it
'returns cadence'
do
post_graphql
(
iteration_cadence_by_id
(
group_or_project
),
current_user:
user
,
variables:
{
id:
cadence_id
})
expect_iteration_cadences_response
(
group_or_project
.
class
.
name
.
downcase
.
to_sym
,
expected_result
)
end
end
it
'returns all group cadences'
do
post_graphql
(
iteration_cadences_query
(
group
),
current_user:
user
)
expect_iteration_cadences_response
(
:group
,
[
iteration_cadence1
,
iteration_cadence2
])
end
context
'by global id'
do
let
(
:cadence_id
)
{
iteration_cadence1
.
to_global_id
.
to_s
}
let
(
:expected_result
)
{
[
iteration_cadence1
]
}
context
'fetching cadences from group level'
do
let
(
:group_or_project
)
{
group
}
it_behaves_like
'returns cadence by id'
context
'from a different group'
do
let
(
:other_group
)
{
create
(
:group
)
}
let
(
:group_or_project
)
{
other_group
}
let
(
:expected_result
)
{
[]
}
it_behaves_like
'returns cadence by id'
end
end
context
'fetching cadences from project level'
do
let
(
:group_or_project
)
{
project
}
it_behaves_like
'returns cadence by id'
end
end
context
'by integer id'
do
let
(
:cadence_id
)
{
iteration_cadence1
.
id
.
to_s
}
let
(
:expected_result
)
{
[
iteration_cadence1
]
}
context
'fetching cadences from group level'
do
let
(
:group_or_project
)
{
group
}
it_behaves_like
'returns cadence by id'
context
'from a different group'
do
let
(
:other_group
)
{
create
(
:group
)
}
let
(
:group_or_project
)
{
other_group
}
let
(
:expected_result
)
{
[]
}
it_behaves_like
'returns cadence by id'
end
end
context
'fetching cadences from project level'
do
let
(
:group_or_project
)
{
project
}
it_behaves_like
'returns cadence by id'
end
end
end
def
iteration_cadences_query
(
group
)
<<~
QUERY
query {
group(fullPath: "
#{
group
.
full_path
}
") {
id,
iterationCadences {
nodes {
id
}
}
}
}
QUERY
end
def
iteration_cadence_by_id
(
parent
)
if
parent
.
is_a?
(
Group
)
<<~
QUERY
query($id: ID!) {
group(fullPath: "
#{
parent
.
full_path
}
") {
id,
iterationCadences(id: $id) {
nodes {
id
}
}
}
}
QUERY
else
<<~
QUERY
query($id: ID!) {
project(fullPath: "
#{
parent
.
full_path
}
") {
id,
iterationCadences(id: $id) {
nodes {
id
}
}
}
}
QUERY
end
end
def
expect_iteration_cadences_response
(
group_or_project
,
cadences
)
actual_cadences
=
graphql_data_at
(
group_or_project
.
to_sym
,
:iterationCadences
,
:nodes
).
map
{
|
cadence
|
cadence
[
'id'
]
}
expected_cadences
=
cadences
.
map
{
|
cadence
|
cadence
.
to_global_id
.
to_s
}
expect
(
actual_cadences
).
to
contain_exactly
(
*
expected_cadences
)
expect
(
graphql_errors
).
to
be_nil
end
end
ee/spec/requests/api/graphql/iterations/iterations_
resolver_
spec.rb
→
ee/spec/requests/api/graphql/iterations/iterations_spec.rb
View file @
23048f87
File moved
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