summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-11-19 01:17:40 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-11-19 01:17:40 +0800
commit92a83aaee1c5715bf95715649aa8ced50a70dea8 (patch)
treefc5c9d7c1ee4f0207ae790c5a1117c8361183e7f
parentb6a7a4783435a7fa34f26dbf3b16ab8e7ed21b88 (diff)
downloadgitlab-ce-92a83aaee1c5715bf95715649aa8ced50a70dea8.tar.gz
Add a test for Ci::Pipeline#cancel_running:
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7508#note_18622559 I didn't write an exhaustive one because we already have it on HasStatus, from: https://gitlab.com/gitlab-org/gitlab-ce/commit/b6a7a4783435a7fa34f26dbf3b16ab8e7ed21b88
-rw-r--r--spec/models/ci/pipeline_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 2cc6d1be606..74579e0c832 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -454,6 +454,22 @@ describe Ci::Pipeline, models: true do
end
end
+ describe '#cancel_running' do
+ context 'when there is a running external job and created build' do
+ before do
+ create(:generic_commit_status, :running, pipeline: pipeline)
+ create(:ci_build, :created, pipeline: pipeline)
+
+ pipeline.cancel_running
+ end
+
+ it 'cancels both jobs' do
+ expect(pipeline.statuses.pluck(:status)).
+ to contain_exactly('canceled', 'canceled')
+ end
+ end
+ end
+
describe '#execute_hooks' do
let!(:build_a) { create_build('a', 0) }
let!(:build_b) { create_build('b', 1) }