diff options
author | George Claghorn <george@basecamp.com> | 2017-12-31 10:36:58 -0500 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2017-12-31 10:36:58 -0500 |
commit | 316d87e412e1c6bc9c7a590b866befbb6bab167f (patch) | |
tree | 81bfdb8d0a2437d0ea94894a31ec743f64189522 /activestorage/test/analyzer | |
parent | 5428c8e3a2d0f80240ac2e3e4b214b775ee2f346 (diff) | |
download | rails-316d87e412e1c6bc9c7a590b866befbb6bab167f.tar.gz rails-316d87e412e1c6bc9c7a590b866befbb6bab167f.tar.bz2 rails-316d87e412e1c6bc9c7a590b866befbb6bab167f.zip |
Append extension to tempfile name
Fixes analyzing an SVG image without an XML declaration. ImageMagick occasionally looks to the extension when it can't discern the type of an image file from its contents.
References #31356.
Diffstat (limited to 'activestorage/test/analyzer')
-rw-r--r-- | activestorage/test/analyzer/image_analyzer_test.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activestorage/test/analyzer/image_analyzer_test.rb b/activestorage/test/analyzer/image_analyzer_test.rb index 9087072215..0d9f24c5c1 100644 --- a/activestorage/test/analyzer/image_analyzer_test.rb +++ b/activestorage/test/analyzer/image_analyzer_test.rb @@ -6,11 +6,19 @@ require "database/setup" require "active_storage/analyzer/image_analyzer" class ActiveStorage::Analyzer::ImageAnalyzerTest < ActiveSupport::TestCase - test "analyzing an image" do + test "analyzing a JPEG image" do blob = create_file_blob(filename: "racecar.jpg", content_type: "image/jpeg") metadata = blob.tap(&:analyze).metadata assert_equal 4104, metadata[:width] assert_equal 2736, metadata[:height] end + + test "analyzing an SVG image without an XML declaration" do + blob = create_file_blob(filename: "icon.svg", content_type: "image/svg+xml") + metadata = blob.tap(&:analyze).metadata + + assert_equal 792, metadata[:width] + assert_equal 584, metadata[:height] + end end |