Commit cc43c9ac authored by Lin Jen-Shin's avatar Lin Jen-Shin

Expand the loop and reduce overlapped conditions

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7508#note_18794681
parent 35669654
...@@ -425,18 +425,36 @@ describe Ci::Pipeline, models: true do ...@@ -425,18 +425,36 @@ describe Ci::Pipeline, models: true do
end end
%i[success failed canceled].each do |status1| %i[success failed canceled].each do |status1|
%i[ci_build generic_commit_status].each do |type0| context "when there are generic_commit_status jobs for #{status0} and #{status1}" do
%i[ci_build generic_commit_status].each do |type1|
context "when there are #{type0} and #{type1} for #{status0} and #{status1}" do
before do before do
create(type0, status0, pipeline: pipeline) create(:generic_commit_status, status0, pipeline: pipeline)
create(type1, status1, pipeline: pipeline) create(:generic_commit_status, status1, pipeline: pipeline)
end end
it 'is cancelable' do it 'is cancelable' do
expect(pipeline.cancelable?).to be_truthy expect(pipeline.cancelable?).to be_truthy
end end
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 end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment