1 require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
3 class GD2Test < Test::Unit::TestCase
4 attachment_model GD2Attachment
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?
12 assert_equal 43, attachment.width
13 assert_equal 55, attachment.height
15 thumb = attachment.thumbnails.detect { |t| t.filename =~ /_thumb/ }
16 geo = attachment.thumbnails.detect { |t| t.filename =~ /_geometry/ }
18 # test exact resize dimensions
19 assert_equal 50, thumb.width
20 assert_equal 51, thumb.height
22 # test geometry string
23 assert_equal 31, geo.width
24 assert_equal 40, geo.height
28 puts "GD2 not loaded, tests not running"