diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index a3bd8fdf30b..0d4c86955ce 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -504,4 +504,42 @@ describe Ci::Pipeline, models: true do end end end + + describe '#has_warnings?' do + subject { pipeline.has_warnings? } + + context 'build which is allowed to fail fails' do + before do + create :ci_build, :success, pipeline: pipeline, name: 'rspec' + create :ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop' + end + + it 'returns true' do + is_expected.to be_truthy + end + end + + context 'build which is allowed to fail succeeds' do + before do + create :ci_build, :success, pipeline: pipeline, name: 'rspec' + create :ci_build, :allowed_to_fail, :success, pipeline: pipeline, name: 'rubocop' + end + + it 'returns false' do + is_expected.to be_falsey + end + end + + context 'build is retried and succeeds' do + before do + create :ci_build, :success, pipeline: pipeline, name: 'rubocop' + create :ci_build, :failed, pipeline: pipeline, name: 'rspec' + create :ci_build, :success, pipeline: pipeline, name: 'rspec' + end + + it 'returns false' do + is_expected.to be_falsey + end + end + end end |