]> projects.mako.cc - selectricity-live/blob - vendor/plugins/attachment_fu/test/processors/mini_magick_test.rb
244a4a2331fe1ae93d34ddcd2156fa697fcaabfa
[selectricity-live] / vendor / plugins / attachment_fu / test / processors / mini_magick_test.rb
1 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
3 class MiniMagickTest < Test::Unit::TestCase
4   attachment_model MiniMagickAttachment
5
6   if Object.const_defined?(:MiniMagick)
7     def test_should_resize_image
8       attachment = upload_file :filename => '/files/rails.png'
9       assert_valid attachment
10       assert attachment.image?
11       # test MiniMagick thumbnail
12       assert_equal 43, attachment.width
13       assert_equal 55, attachment.height
14       
15       thumb      = attachment.thumbnails.detect { |t| t.filename =~ /_thumb/ }
16       geo        = attachment.thumbnails.detect { |t| t.filename =~ /_geometry/ }
17       
18       # test exact resize dimensions
19       assert_equal 50, thumb.width
20       assert_equal 51, thumb.height
21       
22       # test geometry string
23       assert_equal 31, geo.width
24       assert_equal 40, geo.height
25     end
26   else
27     def test_flunk
28       puts "MiniMagick not loaded, tests not running"
29     end
30   end
31 end

Benjamin Mako Hill || Want to submit a patch?