FIX: Refactor commit a8c3ca, add test

This commit is contained in:
Penar Musaraj 2018-11-29 19:11:32 -05:00
parent a58c3ca430
commit ad665b901a
2 changed files with 6 additions and 2 deletions

View File

@ -287,7 +287,7 @@ Discourse SVG subset of #{fa_license}
site_setting_icons = [] site_setting_icons = []
SiteSetting.settings_hash.select do |key, value| SiteSetting.settings_hash.select do |key, value|
if key.to_s.include?("_icon") && value.present? && value.class == String if key.to_s.include?("_icon") && String === value
site_setting_icons |= value.split('|') site_setting_icons |= value.split('|')
end end
end end
@ -317,7 +317,7 @@ Discourse SVG subset of #{fa_license}
# Theme.all includes default values # Theme.all includes default values
Theme.all.each do |theme| Theme.all.each do |theme|
settings = theme.cached_settings.each do |key, value| settings = theme.cached_settings.each do |key, value|
if key.to_s.include?("_icon") && value.present? && value.class == String if key.to_s.include?("_icon") && String === value
theme_icon_settings |= value.split('|') theme_icon_settings |= value.split('|')
end end
end end

View File

@ -83,6 +83,10 @@ describe SvgSprite do
SiteSetting.svg_icon_subset = nil SiteSetting.svg_icon_subset = nil
expect(SvgSprite.all_icons).not_to include("drafting-compass") expect(SvgSprite.all_icons).not_to include("drafting-compass")
# does not fail on non-string setting
SiteSetting.svg_icon_subset = false
expect(SvgSprite.all_icons).to be_truthy
end end
it 'includes icons from plugin registry' do it 'includes icons from plugin registry' do