mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FIX: do not convert format for site setting uploads (#12410)
This commit is contained in:
@ -119,7 +119,6 @@ RSpec.describe UploadCreator do
|
||||
# pngquant will lose some colors causing some extra size reduction
|
||||
expect(thumbnail_size).to be < 7500
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'converting to jpeg' do
|
||||
@ -148,7 +147,6 @@ RSpec.describe UploadCreator do
|
||||
end
|
||||
|
||||
it 'should not store file as jpeg if it does not meet absolute byte saving requirements' do
|
||||
|
||||
# logo.png is 2297 bytes, converting to jpeg saves 30% but does not meet
|
||||
# the absolute savings required of 25_000 bytes, if you save less than that
|
||||
# skip this
|
||||
@ -165,7 +163,6 @@ RSpec.describe UploadCreator do
|
||||
expect(upload.extension).to eq('png')
|
||||
expect(File.extname(upload.url)).to eq('.png')
|
||||
expect(upload.original_filename).to eq('logo.png')
|
||||
|
||||
end
|
||||
|
||||
it 'should store the upload with the right extension' do
|
||||
@ -183,6 +180,14 @@ RSpec.describe UploadCreator do
|
||||
expect(upload.original_filename).to eq('should_be_jpeg.jpg')
|
||||
end
|
||||
|
||||
it "should not convert to jpeg when the image is uploaded from site setting" do
|
||||
upload = UploadCreator.new(large_file, large_filename, for_site_setting: true, force_optimize: true).create_for(user.id)
|
||||
|
||||
expect(upload.extension).to eq('png')
|
||||
expect(File.extname(upload.url)).to eq('.png')
|
||||
expect(upload.original_filename).to eq('large_and_unoptimized.png')
|
||||
end
|
||||
|
||||
context "jpeg image quality settings" do
|
||||
before do
|
||||
SiteSetting.png_to_jpg_quality = 75
|
||||
@ -229,7 +234,6 @@ RSpec.describe UploadCreator do
|
||||
expect(File.extname(upload.url)).to eq('.png')
|
||||
expect(upload.original_filename).to eq('large_and_unoptimized.png')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
it 'should not convert animated WEBP images' do
|
||||
|
Reference in New Issue
Block a user