Commit e17ac92c authored by lauraMon's avatar lauraMon

Adds pipeline cancel and refactors

* Refactors some spec variables
parent ae1c4d0d
# frozen_string_literal: true
module Mutations
module Ci
class PipelineCancel < BaseMutation
graphql_name 'PipelineCancel'
authorize :update_pipeline
def resolve
::Ci::CancelUserPipelinesService.new.execute(current_user)
{
errors: []
}
end
end
end
end
......@@ -62,8 +62,9 @@ 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
mount_mutation Mutations::Ci::PipelineCancel
mount_mutation Mutations::Ci::PipelineDestroy
mount_mutation Mutations::Ci::PipelineRetry
end
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'PipelineCancel' do
include GraphqlHelpers
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, :running, project: project, user: user) }
let(:mutation) do
graphql_mutation(:pipeline_cancel, {},
<<-QL
errors
QL
)
end
before do
project.add_maintainer(user)
end
it 'does not change any pipelines not owned by the current user' do
build = create(:ci_build, :running, pipeline: pipeline)
post_graphql_mutation(mutation, current_user: create(:user))
expect(build).not_to be_canceled
end
it "cancels all of the current user's cancelable pipelines" do
build = create(:ci_build, :running, pipeline: pipeline)
post_graphql_mutation(mutation, current_user: user)
expect(response).to have_gitlab_http_status(:success)
expect(build.reload).to be_canceled
end
end
......@@ -32,7 +32,7 @@ RSpec.describe 'PipelineDestroy' do
expect(graphql_errors).not_to be_empty
end
it 'retries a pipeline' do
it 'destroys a pipeline' do
post_graphql_mutation(mutation, current_user: user)
expect(response).to have_gitlab_http_status(:success)
......
......@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec.describe 'PipelineRetry' do
include GraphqlHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project, user: user) }
let(:mutation) do
......
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