Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
016af097cb
commit
d5e1680713
4 changed files with 20 additions and 8 deletions
|
@ -42,7 +42,7 @@ module IconsHelper
|
|||
end
|
||||
|
||||
def sprite_icon(icon_name, size: nil, css_class: nil)
|
||||
unless known_sprites.include?(icon_name)
|
||||
if known_sprites&.exclude?(icon_name)
|
||||
exception = ArgumentError.new("#{icon_name} is not a known icon in @gitlab-org/gitlab-svg")
|
||||
Gitlab::Sentry.track_and_raise_for_dev_exception(exception)
|
||||
end
|
||||
|
@ -156,6 +156,8 @@ module IconsHelper
|
|||
private
|
||||
|
||||
def known_sprites
|
||||
return if Rails.env.production?
|
||||
|
||||
@known_sprites ||= JSON.parse(File.read(Rails.root.join('node_modules/@gitlab/svgs/dist/icons.json')))['icons']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,9 @@ module Ci
|
|||
# We use a class method here instead of a constant, allowing EE to redefine
|
||||
# the returned `Hash` more easily.
|
||||
def self.failure_reasons
|
||||
{ config_error: 'CI/CD YAML configuration error!' }
|
||||
{ unknown_failure: 'Unknown pipeline failure!',
|
||||
config_error: 'CI/CD YAML configuration error!',
|
||||
external_validation_failure: 'External pipeline validation failed!' }
|
||||
end
|
||||
|
||||
presents :pipeline
|
||||
|
|
|
@ -76,6 +76,8 @@ describe IconsHelper do
|
|||
it 'does not raise in production mode' do
|
||||
stub_rails_env('production')
|
||||
|
||||
expect(File).not_to receive(:read)
|
||||
|
||||
expect { sprite_icon(non_existing) }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,13 +62,19 @@ describe Ci::PipelinePresenter do
|
|||
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
|
||||
describe '#failure_reason' do
|
||||
context 'when pipeline has a failure reason' do
|
||||
::Ci::PipelineEnums.failure_reasons.keys.each do |failure_reason|
|
||||
context "when failure reason is #{failure_reason}" do
|
||||
before do
|
||||
pipeline.failure_reason = failure_reason
|
||||
end
|
||||
|
||||
expect(presenter.failure_reason)
|
||||
.to eq 'CI/CD YAML configuration error!'
|
||||
it 'represents a failure reason sentence' do
|
||||
expect(presenter.failure_reason).to be_an_instance_of(String)
|
||||
expect(presenter.failure_reason).not_to eq(failure_reason.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue