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
9111404d
Commit
9111404d
authored
Jan 21, 2021
by
Jan Provaznik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ResolveResourceParent mixing for iterations
This dries a little bit the code by reusing same logic from mixin.
parent
405e447b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
48 deletions
+10
-48
doc/api/graphql/reference/gitlab_schema.graphql
doc/api/graphql/reference/gitlab_schema.graphql
+2
-2
doc/api/graphql/reference/gitlab_schema.json
doc/api/graphql/reference/gitlab_schema.json
+4
-4
ee/app/graphql/mutations/iterations/create.rb
ee/app/graphql/mutations/iterations/create.rb
+2
-40
ee/spec/requests/api/graphql/mutations/iterations/create_spec.rb
.../requests/api/graphql/mutations/iterations/create_spec.rb
+2
-2
No files found.
doc/api/graphql/reference/gitlab_schema.graphql
View file @
9111404d
...
...
@@ -5095,12 +5095,12 @@ input CreateIterationInput {
dueDate
:
String
"""
The
target
group
for
the
iteration
.
Full
path
of
the
group
with
which
the
resource
is
associated
.
"""
groupPath
:
ID
"""
The
target
project
for
the
iteration
.
Full
path
of
the
project
with
which
the
resource
is
associated
.
"""
projectPath
:
ID
...
...
doc/api/graphql/reference/gitlab_schema.json
View file @
9111404d
...
...
@@ -13827,8 +13827,8 @@
"fields": null,
"inputFields": [
{
"name": "
group
Path",
"description": "
The target group for the iteration
.",
"name": "
project
Path",
"description": "
Full path of the project with which the resource is associated
.",
"type": {
"kind": "SCALAR",
"name": "ID",
...
...
@@ -13837,8 +13837,8 @@
"defaultValue": null
},
{
"name": "
project
Path",
"description": "
The target project for the iteration
.",
"name": "
group
Path",
"description": "
Full path of the group with which the resource is associated
.",
"type": {
"kind": "SCALAR",
"name": "ID",
ee/app/graphql/mutations/iterations/create.rb
View file @
9111404d
...
...
@@ -3,8 +3,7 @@
module
Mutations
module
Iterations
class
Create
<
BaseMutation
include
Mutations
::
ResolvesGroup
include
ResolvesProject
include
Mutations
::
ResolvesResourceParent
graphql_name
'CreateIteration'
...
...
@@ -15,14 +14,6 @@ module Mutations
null:
true
,
description:
'The created iteration.'
argument
:group_path
,
GraphQL
::
ID_TYPE
,
required:
false
,
description:
"The target group for the iteration."
argument
:project_path
,
GraphQL
::
ID_TYPE
,
required:
false
,
description:
"The target project for the iteration."
argument
:title
,
GraphQL
::
STRING_TYPE
,
required:
false
,
...
...
@@ -46,7 +37,7 @@ module Mutations
def
resolve
(
args
)
validate_arguments!
(
args
)
parent
=
find_parent
(
args
)
parent
=
authorized_resource_parent_find!
(
args
)
response
=
::
Iterations
::
CreateService
.
new
(
parent
,
current_user
,
args
).
execute
...
...
@@ -61,40 +52,11 @@ module Mutations
private
def
find_object
(
group_path:
nil
,
project_path:
nil
)
if
group_path
resolve_group
(
full_path:
group_path
)
elsif
project_path
resolve_project
(
full_path:
project_path
)
end
end
def
find_parent
(
args
)
group_path
=
args
.
delete
(
:group_path
)
project_path
=
args
.
delete
(
:project_path
)
if
group_path
authorized_find!
(
group_path:
group_path
)
elsif
project_path
authorized_find!
(
project_path:
project_path
)
end
end
def
validate_arguments!
(
args
)
if
args
.
except
(
:group_path
,
:project_path
).
empty?
raise
Gitlab
::
Graphql
::
Errors
::
ArgumentError
,
'The list of iteration attributes is empty'
end
if
args
[
:group_path
].
present?
&&
args
[
:project_path
].
present?
raise
Gitlab
::
Graphql
::
Errors
::
ArgumentError
,
'Only one of group_path or project_path can be provided'
end
if
args
[
:group_path
].
nil?
&&
args
[
:project_path
].
nil?
raise
Gitlab
::
Graphql
::
Errors
::
ArgumentError
,
'Either group_path or project_path is required'
end
end
end
end
...
...
ee/spec/requests/api/graphql/mutations/iterations/create_spec.rb
View file @
9111404d
...
...
@@ -128,7 +128,7 @@ RSpec.describe 'Creating an Iteration' do
let
(
:params
)
{
{}
}
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
'E
ither group_path or project_path
is required'
]
errors:
[
'E
xactly one of group_path or project_path arguments
is required'
]
it
'does not create the iteration'
do
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
Iteration
,
:count
)
...
...
@@ -139,7 +139,7 @@ RSpec.describe 'Creating an Iteration' do
let
(
:params
)
{
{
group_path:
group
.
full_path
,
project_path:
'doesnotreallymatter'
}
}
it_behaves_like
'a mutation that returns top-level errors'
,
errors:
[
'
Only one of group_path or project_path can be provid
ed'
]
errors:
[
'
Exactly one of group_path or project_path arguments is requir
ed'
]
it
'does not create the iteration'
do
expect
{
post_graphql_mutation
(
mutation
,
current_user:
current_user
)
}.
not_to
change
(
Iteration
,
:count
)
...
...
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