Add spec for 4bf3bf6786
.
This commit is contained in:
parent
f94aeaf6cf
commit
30242972d3
|
@ -252,9 +252,13 @@ class OptimizedImage < ActiveRecord::Base
|
||||||
FileHelper.optimize_image!(to)
|
FileHelper.optimize_image!(to)
|
||||||
true
|
true
|
||||||
rescue => e
|
rescue => e
|
||||||
|
if Rails.env.test?
|
||||||
|
raise e
|
||||||
|
else
|
||||||
Rails.logger.error("Could not optimize image #{to}: #{e.message}")
|
Rails.logger.error("Could not optimize image #{to}: #{e.message}")
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.migrate_to_new_scheme(limit = nil)
|
def self.migrate_to_new_scheme(limit = nil)
|
||||||
problems = []
|
problems = []
|
||||||
|
|
|
@ -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)
|
File.delete(tmp_path) if File.exists?(tmp_path)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
describe '.downsize' do
|
describe '.downsize' do
|
||||||
|
|
Loading…
Reference in New Issue