A platform for community discussion. Free, open, simple.
FIX: Broken spec
Robin Ward6080e3a2c06a
diff --git a/app/models/optimized_image.rb b/app/models/optimized_image.rbindex a80103c7b44..01f870baa6b 100644--- a/app/models/optimized_image.rb+++ b/app/models/optimized_image.rb@@ -174,7 +174,20 @@ class OptimizedImage < ActiveRecord::BaseIM_DECODERS ||= /\A(jpe?g|png|tiff?|bmp|ico|gif)\z/idef self.prepend_decoder!(path, ext_path = nil, opts = nil)- extension = File.extname((opts && opts[:filename]) || path || ext_path)[1..-1]+ opts ||= {}++ # This logic is a little messy but the result of using mocks for most+ # of the image tests. The idea here is you shouldn't trust the "original"+ # path of a file to figure out its extension. However, in certain cases+ # such as generating the loading upload thumbnail, we force the format,+ # and this allows us to use the forced format in that case.+ extension = nil+ if (opts[:format] && path != ext_path)+ extension = File.extname(path)[1..-1]+ else+ extension = File.extname(opts[:filename] || ext_path || path)[1..-1]+ end+raise Discourse::InvalidAccess if !extension || !extension.match?(IM_DECODERS)"#{extension}:#{path}"enddiff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rbindex 6e64ee82b62..aba1b21c02d 100644--- a/spec/models/upload_spec.rb+++ b/spec/models/upload_spec.rb@@ -43,7 +43,6 @@ describe Upload doupload.reloadexpect(upload.optimized_images.count).to eq(1)end-endit "can reconstruct dimensions on demand" do