FIX: always test and coerce to image on upload

In the past the filename of the origin was used as the source
for the extension of the file when optimizing on upload.

We now use the actual calculated extension based on upload data.
This commit is contained in:
Sam
2018-08-20 12:18:49 +10:00
parent 975a72ab7a
commit 8b5e42ea16
5 changed files with 66 additions and 21 deletions

View File

@ -26,7 +26,7 @@ RSpec.describe UploadCreator do
end
describe 'when image has the wrong extension' do
let(:filename) { "png_as.jpg" }
let(:filename) { "png_as.bin" }
let(:file) { file_from_fixtures(filename) }
it 'should store the upload with the right extension' do
@ -41,7 +41,7 @@ RSpec.describe UploadCreator do
expect(upload.extension).to eq('png')
expect(File.extname(upload.url)).to eq('.png')
expect(upload.original_filename).to eq('png_as.jpg')
expect(upload.original_filename).to eq('png_as.bin.fixed.png')
end
end
@ -65,7 +65,7 @@ RSpec.describe UploadCreator do
expect(upload.extension).to eq('jpeg')
expect(File.extname(upload.url)).to eq('.jpeg')
expect(upload.original_filename).to eq('logo.png')
expect(upload.original_filename).to eq('logo.png.fixed.jpeg')
end
end
end