summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-11-22 19:07:12 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-11-22 19:07:12 +0800
commitcc43c9acc29117cd9ec3c25805e6c5ea874e5969 (patch)
treea1ab1b48e58c3b683ac2eecb9d00eac1ab97f6d2
parent3566965417b7921cdb301c44cfb308551cdc1e82 (diff)
downloadgitlab-ce-cc43c9acc29117cd9ec3c25805e6c5ea874e5969.tar.gz
Expand the loop and reduce overlapped conditions
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7508#note_18794681
-rw-r--r--spec/models/ci/pipeline_spec.rb42
1 files changed, 30 insertions, 12 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 03924a436de..438810d8206 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -425,18 +425,36 @@ describe Ci::Pipeline, models: true do
end
%i[success failed canceled].each do |status1|
- %i[ci_build generic_commit_status].each do |type0|
- %i[ci_build generic_commit_status].each do |type1|
- context "when there are #{type0} and #{type1} for #{status0} and #{status1}" do
- before do
- create(type0, status0, pipeline: pipeline)
- create(type1, status1, pipeline: pipeline)
- end
-
- it 'is cancelable' do
- expect(pipeline.cancelable?).to be_truthy
- end
- end
+ context "when there are generic_commit_status jobs for #{status0} and #{status1}" do
+ before do
+ create(:generic_commit_status, status0, pipeline: pipeline)
+ create(:generic_commit_status, status1, pipeline: pipeline)
+ end
+
+ it 'is cancelable' do
+ expect(pipeline.cancelable?).to be_truthy
+ end
+ end
+
+ context "when there are generic_commit_status and ci_build jobs for #{status0} and #{status1}" do
+ before do
+ create(:generic_commit_status, status0, pipeline: pipeline)
+ create(:ci_build, status1, pipeline: pipeline)
+ end
+
+ it 'is cancelable' do
+ expect(pipeline.cancelable?).to be_truthy
+ end
+ end
+
+ context "when there are ci_build jobs for #{status0} and #{status1}" do
+ before do
+ create(:ci_build, status0, pipeline: pipeline)
+ create(:ci_build, status1, pipeline: pipeline)
+ end
+
+ it 'is cancelable' do
+ expect(pipeline.cancelable?).to be_truthy
end
end
end