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
fc73d77c
Commit
fc73d77c
authored
Aug 13, 2020
by
lauraMon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds retryPipeline mutation
* First unrefactored spec
parent
a0efb830
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
137 additions
and
0 deletions
+137
-0
app/graphql/mutations/ci/base.rb
app/graphql/mutations/ci/base.rb
+25
-0
app/graphql/mutations/ci/pipeline_retry.rb
app/graphql/mutations/ci/pipeline_retry.rb
+21
-0
app/graphql/types/mutation_type.rb
app/graphql/types/mutation_type.rb
+1
-0
spec/requests/api/graphql/mutations/ci/cancel_pipeline_spec.rb
...requests/api/graphql/mutations/ci/cancel_pipeline_spec.rb
+45
-0
spec/requests/api/graphql/mutations/ci/retry_pipeline_spec.rb
.../requests/api/graphql/mutations/ci/retry_pipeline_spec.rb
+45
-0
No files found.
app/graphql/mutations/ci/base.rb
0 → 100644
View file @
fc73d77c
# frozen_string_literal: true
module
Mutations
module
Ci
class
Base
<
BaseMutation
argument
:id
,
GraphQL
::
ID_TYPE
,
required:
true
,
description:
'The id of the pipeline to mutate'
field
:pipeline
,
Types
::
Ci
::
PipelineType
,
null:
true
,
description:
'The pipeline after mutation'
authorize
:update_pipeline
private
def
find_object
(
id
:)
::
Ci
::
Pipeline
.
find
(
id
)
end
end
end
end
app/graphql/mutations/ci/pipeline_retry.rb
0 → 100644
View file @
fc73d77c
# frozen_string_literal: true
module
Mutations
module
Ci
class
PipelineRetry
<
Base
graphql_name
'PipelineRetry'
def
resolve
(
id
:)
pipeline
=
authorized_find!
(
id:
id
)
project
=
pipeline
.
project
::
Ci
::
RetryPipelineService
.
new
(
project
,
current_user
).
execute
(
pipeline
)
{
pipeline:
pipeline
,
errors:
errors_on_object
(
pipeline
)
}
end
end
end
end
app/graphql/types/mutation_type.rb
View file @
fc73d77c
...
...
@@ -62,6 +62,7 @@ module Types
mount_mutation
Mutations
::
DesignManagement
::
Delete
,
calls_gitaly:
true
mount_mutation
Mutations
::
DesignManagement
::
Move
mount_mutation
Mutations
::
ContainerExpirationPolicies
::
Update
mount_mutation
Mutations
::
Ci
::
PipelineRetry
end
end
...
...
spec/requests/api/graphql/mutations/ci/cancel_pipeline_spec.rb
0 → 100644
View file @
fc73d77c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'PipelineCancel'
do
include
GraphqlHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
let
(
:mutation
)
do
variables
=
{
id:
pipeline
.
id
}
graphql_mutation
(
:pipeline_retry
,
variables
,
<<-
QL
errors
pipeline {
id
}
QL
)
end
let
(
:mutation_response
)
{
graphql_mutation_response
(
:pipeline_cancel
)
}
before
do
project
.
add_maintainer
(
user
)
end
it
'returns an error if the user is not allowed to retry the pipeline'
do
post_graphql_mutation
(
mutation
,
current_user:
create
(
:user
))
expect
(
graphql_errors
).
not_to
be_empty
end
it
'retries a pipeline'
do
post_graphql_mutation
(
mutation
,
current_user:
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
mutation_response
[
'pipeline'
][
'id'
]).
to
include
(
pipeline
.
id
.
to_s
)
end
end
spec/requests/api/graphql/mutations/ci/retry_pipeline_spec.rb
0 → 100644
View file @
fc73d77c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'PipelineRetry'
do
include
GraphqlHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
,
user:
user
)
}
let
(
:mutation
)
do
variables
=
{
id:
pipeline
.
id
}
graphql_mutation
(
:pipeline_retry
,
variables
,
<<-
QL
errors
pipeline {
id
}
QL
)
end
let
(
:mutation_response
)
{
graphql_mutation_response
(
:pipeline_retry
)
}
before
do
project
.
add_maintainer
(
user
)
end
it
'returns an error if the user is not allowed to retry the pipeline'
do
post_graphql_mutation
(
mutation
,
current_user:
create
(
:user
))
expect
(
graphql_errors
).
not_to
be_empty
end
it
'retries a pipeline'
do
pipeline_id
=
::
Gitlab
::
GlobalId
.
build
(
pipeline
,
id:
pipeline
.
id
).
to_s
post_graphql_mutation
(
mutation
,
current_user:
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:success
)
expect
(
mutation_response
[
'pipeline'
][
'id'
]).
to
eq
(
pipeline_id
)
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