correct regression uploading images

This commit is contained in:
Sam 2018-08-16 18:48:02 +10:00
parent 937ab3f213
commit f62073a22a
2 changed files with 5 additions and 2 deletions

View File

@ -125,8 +125,8 @@ class OptimizedImage < ActiveRecord::Base
IM_DECODERS ||= /\A(jpe?g|png|tiff?|bmp|ico|gif)\z/i
def self.prepend_decoder!(path, ext_path)
extension = File.extname(ext_path)[1..-1]
def self.prepend_decoder!(path, ext_path = nil)
extension = File.extname(ext_path || path)[1..-1]
raise Discourse::InvalidAccess unless extension.present? && extension[IM_DECODERS]
"#{extension}:#{path}"
end

View File

@ -57,6 +57,9 @@ describe UserAvatarsController do
expect(OptimizedImage.where(upload_id: upload.id).count).to eq(1)
expect(response.status).to eq(200)
upload.reload
expect(upload.extension).to eq('png')
end
end