mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Converting PNG to JPEG does not set the correct extension.
This commit is contained in:
@@ -163,46 +163,6 @@ describe UploadsController do
|
||||
message = JSON.parse(response.body)["errors"]
|
||||
expect(message).to contain_exactly(I18n.t("upload.images.size_not_found"))
|
||||
end
|
||||
|
||||
describe 'when upload is not an image' do
|
||||
before do
|
||||
SiteSetting.authorized_extensions = 'txt'
|
||||
end
|
||||
|
||||
let(:file) do
|
||||
Rack::Test::UploadedFile.new(file_from_fixtures("utf-8.txt", "encodings"))
|
||||
end
|
||||
|
||||
it 'should store the upload with the right extension' do
|
||||
expect do
|
||||
post "/uploads.json", params: { file: file, type: "composer" }
|
||||
end.to change { Upload.count }.by(1)
|
||||
|
||||
upload = Upload.last
|
||||
|
||||
expect(upload.extension).to eq('txt')
|
||||
expect(File.extname(upload.url)).to eq('.txt')
|
||||
expect(upload.original_filename).to eq('utf-8.txt')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when image has the wrong extension' do
|
||||
let(:file) do
|
||||
Rack::Test::UploadedFile.new(file_from_fixtures("png_as.jpg"))
|
||||
end
|
||||
|
||||
it 'should store the upload with the right extension' do
|
||||
expect do
|
||||
post "/uploads.json", params: { file: file, type: "avatar" }
|
||||
end.to change { Upload.count }.by(1)
|
||||
|
||||
upload = Upload.last
|
||||
|
||||
expect(upload.extension).to eq('png')
|
||||
expect(File.extname(upload.url)).to eq('.png')
|
||||
expect(upload.original_filename).to eq('png_as.png')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user