FIX: correct svg handling for images

We regressed and optimized images no longer worked with svg

The following adds the correct logic to simply copy file for svgs
and bypasses resizing for svg avatars
This commit is contained in:
Sam
2018-11-07 15:29:14 +11:00
parent 7534042427
commit 0a442e319c
4 changed files with 21 additions and 5 deletions

View File

@ -185,6 +185,21 @@ describe OptimizedImage do
describe ".create_for" do
it "is able to 'optimize' an svg" do
# we don't really optimize anything, we simply copy
# but at least this confirms this actually works
SiteSetting.authorized_extensions = 'svg'
svg = file_from_fixtures('image.svg')
upload = UploadCreator.new(svg, 'image.svg').create_for(Discourse.system_user.id)
resized = upload.get_optimized_image(50, 50, {})
# we perform some basic svg mangling but expect the string Discourse to be there
expect(File.read(Discourse.store.path_for(resized))).to include("Discourse")
expect(File.read(Discourse.store.path_for(resized))).to eq(File.read(Discourse.store.path_for(upload)))
end
context "when using an internal store" do
let(:store) { FakeInternalStore.new }