From f71a9de14d118fb14666df9f78365779308312e1 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 19 May 2017 20:42:05 +0200 Subject: Exclude manual actions from cancelable jobs scope --- app/models/concerns/has_status.rb | 2 +- .../fix-gb-exclude-manual-actions-from-cancelable-jobs.yml | 4 ++++ spec/models/ci/pipeline_spec.rb | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/fix-gb-exclude-manual-actions-from-cancelable-jobs.yml diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb index dff7b6e3523..3c9c6584e02 100644 --- a/app/models/concerns/has_status.rb +++ b/app/models/concerns/has_status.rb @@ -82,7 +82,7 @@ module HasStatus scope :failed_or_canceled, -> { where(status: [:failed, :canceled]) } scope :cancelable, -> do - where(status: [:running, :pending, :created, :manual]) + where(status: [:running, :pending, :created]) end end diff --git a/changelogs/unreleased/fix-gb-exclude-manual-actions-from-cancelable-jobs.yml b/changelogs/unreleased/fix-gb-exclude-manual-actions-from-cancelable-jobs.yml new file mode 100644 index 00000000000..a16fc775b5e --- /dev/null +++ b/changelogs/unreleased/fix-gb-exclude-manual-actions-from-cancelable-jobs.yml @@ -0,0 +1,4 @@ +--- +title: Exclude manual actions when checking if pipeline can be canceled +merge_request: 11562 +author: diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 157d17fbb68..56b24ce62f3 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -854,6 +854,16 @@ describe Ci::Pipeline, models: true do end end end + + context 'when there is a manual action present in the pipeline' do + before do + create(:ci_build, :manual, pipeline: pipeline) + end + + it 'is not cancelable' do + expect(pipeline).not_to be_cancelable + end + end end describe '#cancel_running' do -- cgit v1.2.1