Add spec for 4bf3bf6786
.
This commit is contained in:
parent
f94aeaf6cf
commit
30242972d3
|
@ -252,8 +252,12 @@ class OptimizedImage < ActiveRecord::Base
|
|||
FileHelper.optimize_image!(to)
|
||||
true
|
||||
rescue => e
|
||||
Rails.logger.error("Could not optimize image #{to}: #{e.message}")
|
||||
false
|
||||
if Rails.env.test?
|
||||
raise e
|
||||
else
|
||||
Rails.logger.error("Could not optimize image #{to}: #{e.message}")
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def self.migrate_to_new_scheme(limit = nil)
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<svg width="1" height="1">
|
||||
<image xlink:href="https://www.discourse.org" />
|
||||
</svg>
|
After Width: | Height: | Size: 83 B |
|
@ -45,6 +45,25 @@ describe OptimizedImage do
|
|||
File.delete(tmp_path) if File.exists?(tmp_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when an svg with a href is masked as a png' do
|
||||
it 'should not trigger the external request' do
|
||||
tmp_path = "/tmp/resized.png"
|
||||
|
||||
begin
|
||||
expect do
|
||||
OptimizedImage.resize(
|
||||
"#{Rails.root}/spec/fixtures/images/svg.png",
|
||||
tmp_path,
|
||||
5,
|
||||
5
|
||||
)
|
||||
end.to raise_error(RuntimeError, /improper image header/)
|
||||
ensure
|
||||
File.delete(tmp_path) if File.exists?(tmp_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.downsize' do
|
||||
|
|
Loading…
Reference in New Issue