summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-04-06 21:32:56 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-04-06 21:32:56 +0800
commit057c0d7a5c062f3030bcc46614ef2442009002de (patch)
treee4e9f8b092500950e914955f8d257c3b443a77dd /spec/models
parent98a4aca6b5ce503543b0e325212265a365e64d75 (diff)
downloadgitlab-ce-057c0d7a5c062f3030bcc46614ef2442009002de.tar.gz
Also track auto-cancelling in jobs, detail:
Not only tracking auto-cancelling in pipelines, we'll also track this in jobs because pipelines could be retried and the information would get lost when this happened. Also erase auto-cancelling relation for pipelines when they're retried.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/pipeline_spec.rb37
-rw-r--r--spec/models/commit_status_spec.rb26
2 files changed, 63 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 38d3be926aa..3595601a72d 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -136,6 +136,43 @@ describe Ci::Pipeline, models: true do
end
end
+ describe '#auto_canceled?' do
+ subject { pipeline.auto_canceled? }
+
+ context 'when it is canceled' do
+ before do
+ pipeline.cancel
+ end
+
+ context 'when there is auto_canceled_by' do
+ before do
+ pipeline.update(auto_canceled_by: create(:ci_empty_pipeline))
+ end
+
+ it 'is auto canceled' do
+ is_expected.to be_truthy
+ end
+ end
+
+ context 'when there is no auto_canceled_by' do
+ it 'is not auto canceled' do
+ is_expected.to be_falsey
+ end
+ end
+
+ context 'when it is retried and canceled manually' do
+ before do
+ pipeline.enqueue
+ pipeline.cancel
+ end
+
+ it 'is not auto canceled' do
+ is_expected.to be_falsey
+ end
+ end
+ end
+ end
+
describe 'pipeline stages' do
before do
create(:commit_status, pipeline: pipeline,
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index 7343b735a74..3bffb8dba72 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -101,6 +101,32 @@ describe CommitStatus, :models do
end
end
+ describe '#auto_canceled?' do
+ subject { commit_status.auto_canceled? }
+
+ context 'when it is canceled' do
+ before do
+ commit_status.cancel
+ end
+
+ context 'when there is auto_canceled_by' do
+ before do
+ commit_status.update(auto_cancel_by: create(:ci_empty_pipeline))
+ end
+
+ it 'is auto canceled' do
+ is_expected.to be_truthy
+ end
+ end
+
+ context 'when there is no auto_canceled_by' do
+ it 'is not auto canceled' do
+ is_expected.to be_falsey
+ end
+ end
+ end
+ end
+
describe '#duration' do
subject { commit_status.duration }