Commit fd115bc1 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Add specs for two new methods defined in stage class

parent 8dbd1e7d
...@@ -42,7 +42,6 @@ describe Gitlab::Ci::Status::Stage::Factory do ...@@ -42,7 +42,6 @@ describe Gitlab::Ci::Status::Stage::Factory do
end end
end end
end end
end end
context 'when stage has warnings' do context 'when stage has warnings' do
......
...@@ -142,6 +142,54 @@ describe Ci::Stage, models: true do ...@@ -142,6 +142,54 @@ describe Ci::Stage, models: true do
end end
end end
describe '#success?' do
context 'when stage is successful' do
before do
create_job(:ci_build, status: :success)
create_job(:generic_commit_status, status: :success)
end
it 'is successful' do
expect(stage).to be_success
end
end
context 'when stage is not successful' do
before do
create_job(:ci_build, status: :failed)
create_job(:generic_commit_status, status: :success)
end
it 'is not successful' do
expect(stage).not_to be_success
end
end
end
describe '#has_warnings?' do
context 'when stage has warnings' do
before do
create(:ci_build, :failed, :allowed_to_fail,
stage: stage_name, pipeline: pipeline)
end
it 'has warnings' do
expect(stage).to have_warnings
end
end
context 'when stage does not have warnings' do
before do
create(:ci_build, :success, stage: stage_name,
pipeline: pipeline)
end
it 'does not have warnings' do
expect(stage).not_to have_warnings
end
end
end
def create_job(type, status: 'success', stage: stage_name) def create_job(type, status: 'success', stage: stage_name)
create(type, pipeline: pipeline, stage: stage, status: status) create(type, pipeline: pipeline, stage: stage, status: status)
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