diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-01-09 13:07:52 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-01-11 13:53:17 +0100 |
commit | fd115bc130a8bf77814262b67eb0f20f1f19cb85 (patch) | |
tree | e13d684351d4eda357b9a768257941b3e46ad0a4 /spec/models/ci | |
parent | 8dbd1e7d0000bb08b6ac6867530bb501eadc85a4 (diff) | |
download | gitlab-ce-fd115bc130a8bf77814262b67eb0f20f1f19cb85.tar.gz |
Add specs for two new methods defined in stage class
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/stage_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb index 742bedb37e4..3d387d52c8e 100644 --- a/spec/models/ci/stage_spec.rb +++ b/spec/models/ci/stage_spec.rb @@ -142,6 +142,54 @@ describe Ci::Stage, models: true do 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) create(type, pipeline: pipeline, stage: stage, status: status) end |