Commit 66a3b645 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '56475-all-pages-that-render-icons-return-500' into 'master'

Resolve "All pages that render icons return 500"

See merge request gitlab-org/gitlab!21783
parents 3e6414b7 615c90c6
......@@ -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
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment