mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-20 14:11:11 +00:00
Improve specs for pipeline failure reason presenter
Conflicts: app/presenters/ci/pipeline_presenter.rb
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
module Ci
|
||||
class PipelinePresenter < Gitlab::View::Presenter::Delegated
|
||||
FAILURE_REASONS = {}
|
||||
FAILURE_REASONS = {
|
||||
config_error: 'CI/CD YAML configuration error!'
|
||||
}.freeze
|
||||
|
||||
presents :pipeline
|
||||
|
||||
def failure_reason
|
||||
return unless pipeline.failure_reason?
|
||||
|
@ -51,4 +51,21 @@ describe Ci::PipelinePresenter do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context '#failure_reason' do
|
||||
context 'when pipeline has failure reason' do
|
||||
it 'represents a failure reason sentence' do
|
||||
pipeline.failure_reason = :config_error
|
||||
|
||||
expect(presenter.failure_reason)
|
||||
.to eq 'CI/CD YAML configuration error!'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when pipeline does not have failure reason' do
|
||||
it 'returns nil' do
|
||||
expect(presenter.failure_reason).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -108,5 +108,18 @@ describe PipelineEntity do
|
||||
expect(subject[:ref][:path]).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'when pipeline has a failure reason set' do
|
||||
let(:pipeline) { create(:ci_empty_pipeline) }
|
||||
|
||||
before do
|
||||
pipeline.drop!(:config_error)
|
||||
end
|
||||
|
||||
it 'has a correct failure reason' do
|
||||
expect(subject[:failure_reason])
|
||||
.to eq 'CI/CD YAML configuration error!'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user