From 4c1905fd66aa571361829b85d84604e37058848a Mon Sep 17 00:00:00 2001 From: Jeremy Venezia Date: Tue, 1 Dec 2015 17:49:05 +0100 Subject: [PATCH] raise UnknownImageType when file is non-svg xml --- lib/fastimage.rb | 8 +++++++- test/fixtures/test.xml | 3 +++ test/test.rb | 9 ++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/test.xml diff --git a/lib/fastimage.rb b/lib/fastimage.rb index 72cbcb5..77a4b7e 100644 --- a/lib/fastimage.rb +++ b/lib/fastimage.rb @@ -436,8 +436,14 @@ class FastImage else raise UnknownImageType end - when " + + \ No newline at end of file diff --git a/test/test.rb b/test/test.rb index fd301fb..89b7192 100644 --- a/test/test.rb +++ b/test/test.rb @@ -37,7 +37,8 @@ GoodFixtures = { BadFixtures = [ "faulty.jpg", - "test_rgb.ct" + "test_rgb.ct", + "test.xml" ] # man.ico courtesy of http://www.iconseeker.com/search-icon/artists-valley-sample/business-man-blue.html # test_rgb.ct courtesy of http://fileformats.archiveteam.org/wiki/Scitex_CT @@ -122,6 +123,12 @@ class FastImageTest < Test::Unit::TestCase end end + def test_should_raise_unknown_image_typ_when_file_is_non_svg_xml + assert_raises(FastImage::UnknownImageType) do + FastImage.size(TestUrl + "test.xml", :raise_on_failure=>true) + end + end + def test_should_report_type_correctly_for_local_files GoodFixtures.each do |fn, info| assert_equal info[0], FastImage.type(File.join(FixturePath, fn))