Commit eb7cd131 authored by lauraMon's avatar lauraMon

Adds PipelineDestroy mutation

* Adds first spec
parent fc73d77c
...@@ -14,6 +14,7 @@ module Mutations ...@@ -14,6 +14,7 @@ module Mutations
description: 'The pipeline after mutation' description: 'The pipeline after mutation'
authorize :update_pipeline authorize :update_pipeline
authorize :destroy_pipeline
private private
......
# frozen_string_literal: true
module Mutations
module Ci
class PipelineDestroy < Base
graphql_name 'PipelineDestroy'
def resolve(id:)
pipeline = authorized_find!(id: id)
project = pipeline.project
::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline)
{
errors: []
}
end
end
end
end
...@@ -63,6 +63,7 @@ module Types ...@@ -63,6 +63,7 @@ module Types
mount_mutation Mutations::DesignManagement::Move mount_mutation Mutations::DesignManagement::Move
mount_mutation Mutations::ContainerExpirationPolicies::Update mount_mutation Mutations::ContainerExpirationPolicies::Update
mount_mutation Mutations::Ci::PipelineRetry mount_mutation Mutations::Ci::PipelineRetry
mount_mutation Mutations::Ci::PipelineDestroy
end end
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'PipelineDestroy' do
include GraphqlHelpers
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, :success, project: project, user: user) }
let(:mutation) do
variables = {
id: pipeline.id
}
graphql_mutation(:pipeline_destroy, variables,
<<-QL
errors
QL
)
end
let(:mutation_response) { graphql_mutation_response(:pipeline_destroy) }
before do
project.add_maintainer(user)
end
it 'returns an error if the user is not allowed to destroy 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)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment