gitlab-org--gitlab-foss/app/presenters/ci/pipeline_presenter.rb
gfyoung d5bf57a6af Enable frozen string in presenters and policies
Enable frozen string in:

* app/presenters
* app/policies

Partially addresses #47424.
2018-07-24 13:18:25 -07:00

34 lines
776 B
Ruby

# frozen_string_literal: true
module Ci
class PipelinePresenter < Gitlab::View::Presenter::Delegated
include Gitlab::Utils::StrongMemoize
FAILURE_REASONS = {
config_error: 'CI/CD YAML configuration error!'
}.freeze
presents :pipeline
def failed_builds
return [] unless can?(current_user, :read_build, pipeline)
strong_memoize(:failed_builds) do
pipeline.builds.latest.failed
end
end
def failure_reason
return unless pipeline.failure_reason?
FAILURE_REASONS[pipeline.failure_reason.to_sym] ||
pipeline.failure_reason
end
def status_title
if auto_canceled?
"Pipeline is redundant and is auto-canceled by Pipeline ##{auto_canceled_by_id}"
end
end
end
end