A platform for community discussion. Free, open, simple.
FIX: do not raise exception when svg path is nil (#13844)
Krzysztof Kotlarek88aa0136e372
diff --git a/app/models/theme_field.rb b/app/models/theme_field.rbindex 847745642c2..603e1f0eaf0 100644--- a/app/models/theme_field.rb+++ b/app/models/theme_field.rb@@ -180,10 +180,10 @@ class ThemeField < ActiveRecord::Basepath = Discourse.store.path_for(upload)end- content = File.read(path)error = nilbegin+ content = File.read(path)svg_file = Nokogiri::XML(content) do |config|config.options = Nokogiri::XML::ParseOptions::NOBLANKSenddiff --git a/spec/models/theme_field_spec.rb b/spec/models/theme_field_spec.rbindex 9854ce3084a..5ebc77dc478 100644--- a/spec/models/theme_field_spec.rb+++ b/spec/models/theme_field_spec.rb@@ -430,6 +430,11 @@ HTMLtheme_field.destroy!expect(SvgSprite.custom_svg_sprites(theme.id).size).to eq(0)end++ it 'crashes gracefully when svg is invalid' do+ FileStore::LocalStore.any_instance.stubs(:path_for).returns(nil)+ expect(theme_field.validate_svg_sprite_xml).to match("Error with icons-sprite")+ endendend