Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-11-16 19:57:50 +0300
committerLin Jen-Shin <godfat@godfat.org>2016-11-17 15:22:57 +0300
commit6d1c5761cd520f3cb7fa4dbb1a1937c29f468884 (patch)
treed5edc1d78a744d62bbe6832b10a022ac12fc63a6 /spec/models/ci
parent891465ba8cd57bb928e82ba070f2d7efb63f6282 (diff)
Improve how we could cancel pipelines:
* Introduce `HasStatus.cancelable` which we might be able to cancel * Cancel and check upon `cancelable` * Also cancel on `CommitStatus` rather than just `Ci::Build` Fixes #23635 Fixes #17845
Diffstat (limited to 'spec/models/ci')
-rw-r--r--spec/models/ci/pipeline_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 71b7628ef10..d013dc7b31a 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -402,6 +402,46 @@ describe Ci::Pipeline, models: true do
end
end
+ describe '#cancelable?' do
+ subject { pipeline.cancelable? }
+
+ %i[created running pending].each do |status|
+ context "when there is a build #{status}" do
+ before do
+ create(:ci_build, status, pipeline: pipeline)
+ end
+
+ it { is_expected.to be_truthy }
+ end
+
+ context "when there is an external job #{status}" do
+ before do
+ create(:generic_commit_status, status, pipeline: pipeline)
+ end
+
+ it { is_expected.to be_truthy }
+ end
+ end
+
+ %i[success failed canceled].each do |status|
+ context "when there is a build #{status}" do
+ before do
+ create(:ci_build, status, pipeline: pipeline)
+ end
+
+ it { is_expected.to be_falsey }
+ end
+
+ context "when there is an external job #{status}" do
+ before do
+ create(:generic_commit_status, status, pipeline: pipeline)
+ end
+
+ it { is_expected.to be_falsey }
+ end
+ end
+ end
+
describe '#execute_hooks' do
let!(:build_a) { create_build('a', 0) }
let!(:build_b) { create_build('b', 1) }