merged in from code from the other master
[selectricity] / vendor / plugins / attachment_fu / test / processors / core_image_test.rb
1 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
3 class CoreImageTest < Test::Unit::TestCase
4   attachment_model CoreImageAttachment
5
6   if Object.const_defined?(:OSX)
7     def test_should_resize_image
8       attachment = upload_file :filename => '/files/rails.png'
9       assert_valid attachment
10       assert attachment.image?
11       # test core image thumbnail
12       assert_equal 42, 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 41, geo.height
25       
26       # This makes sure that we didn't overwrite the original file
27       # and will end up with a thumbnail instead of the original
28       assert_equal 42, attachment.width
29       assert_equal 55, attachment.height
30       
31     end
32   else
33     def test_flunk
34       puts "CoreImage not loaded, tests not running"
35     end
36   end
37 end

Benjamin Mako Hill || Want to submit a patch?