Test against all possible cases, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7508#note_18755739
This commit is contained in:
parent
d09d6ad01d
commit
c7c4850d0b
|
@ -403,10 +403,10 @@ describe Ci::Pipeline, models: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#cancelable?' do
|
describe '#cancelable?' do
|
||||||
%i[created running pending].each do |status|
|
%i[created running pending].each do |status0|
|
||||||
context "when there is a build #{status}" do
|
context "when there is a build #{status0}" do
|
||||||
before do
|
before do
|
||||||
create(:ci_build, status, pipeline: pipeline)
|
create(:ci_build, status0, pipeline: pipeline)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is cancelable' do
|
it 'is cancelable' do
|
||||||
|
@ -414,9 +414,9 @@ describe Ci::Pipeline, models: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when there is an external job #{status}" do
|
context "when there is an external job #{status0}" do
|
||||||
before do
|
before do
|
||||||
create(:generic_commit_status, status, pipeline: pipeline)
|
create(:generic_commit_status, status0, pipeline: pipeline)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is cancelable' do
|
it 'is cancelable' do
|
||||||
|
@ -424,16 +424,19 @@ describe Ci::Pipeline, models: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i[success failed canceled].each do |status2|
|
%i[success failed canceled].each do |status1|
|
||||||
context "when there are two builds for #{status} and #{status2}" do
|
%i[ci_build generic_commit_status].each do |type0|
|
||||||
before do
|
%i[ci_build generic_commit_status].each do |type1|
|
||||||
build = %i[ci_build generic_commit_status]
|
context "when there are #{type0} and #{type1} for #{status0} and #{status1}" do
|
||||||
create(build.sample, status, pipeline: pipeline)
|
before do
|
||||||
create(build.sample, status2, pipeline: pipeline)
|
create(type0, status0, pipeline: pipeline)
|
||||||
end
|
create(type1, status1, pipeline: pipeline)
|
||||||
|
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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue