]> projects.mako.cc - selectricity/blob - vendor/plugins/attachment_fu/test/processors/gd2_test.rb
referenced mailing list and gitorious
[selectricity] / vendor / plugins / attachment_fu / test / processors / gd2_test.rb
1 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
2
3 class GD2Test < Test::Unit::TestCase
4   attachment_model GD2Attachment
5
6   if Object.const_defined?(:GD2)
7     def test_should_resize_image
8       attachment = upload_file :filename => '/files/rails.png'
9       assert_valid attachment
10       assert attachment.image?
11       # test gd2 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 "GD2 not loaded, tests not running"
29     end
30   end
31 end

Benjamin Mako Hill || Want to submit a patch?