gitlab-org--gitlab-foss/lib/gitlab/ci/status/build/failed.rb
gfyoung 5186d6faa1 Enable frozen string for lib/gitlab/ci/**/*.rb
Enables frozen string for all remaining files
in lib/gitlab/ci.

Partially addresses #47424.
2018-10-30 13:39:30 -07:00

55 lines
1.3 KiB
Ruby

# frozen_string_literal: true
module Gitlab
module Ci
module Status
module Build
class Failed < Status::Extended
REASONS = {
unknown_failure: 'unknown failure',
script_failure: 'script failure',
api_failure: 'API failure',
stuck_or_timeout_failure: 'stuck or timeout failure',
runner_system_failure: 'runner system failure',
missing_dependency_failure: 'missing dependency failure',
runner_unsupported: 'unsupported runner',
stale_schedule: 'stale schedule',
job_execution_timeout: 'job execution timeout'
}.freeze
private_constant :REASONS
def status_tooltip
base_message
end
def badge_tooltip
base_message
end
def self.matches?(build, user)
build.failed?
end
def self.reasons
REASONS
end
private
def base_message
"#{s_('CiStatusLabel|failed')} #{description}"
end
def description
"- (#{failure_reason_message})"
end
def failure_reason_message
self.class.reasons.fetch(subject.failure_reason.to_sym)
end
end
end
end
end
end