]> projects.mako.cc - selectricity/blob - vendor/plugins/attachment_fu/test/extra_attachment_test.rb
Embeddable elctions now scale based on how many candidates in the election there...
[selectricity] / vendor / plugins / attachment_fu / test / extra_attachment_test.rb
1 require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
2
3 class OrphanAttachmentTest < Test::Unit::TestCase
4   include BaseAttachmentTests
5   attachment_model OrphanAttachment
6   
7   def test_should_create_image_from_uploaded_file
8     assert_created do
9       attachment = upload_file :filename => '/files/rails.png'
10       assert_valid attachment
11       assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
12       assert  attachment.image?
13       assert !attachment.size.zero?
14     end
15   end
16   
17   def test_should_create_file_from_uploaded_file
18     assert_created do
19       attachment = upload_file :filename => '/files/foo.txt'
20       assert_valid attachment
21       assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
22       assert  attachment.image?
23       assert !attachment.size.zero?
24     end
25   end
26   
27   def test_should_create_image_from_uploaded_file_with_custom_content_type
28     assert_created do
29       attachment = upload_file :content_type => 'foo/bar', :filename => '/files/rails.png'
30       assert_valid attachment
31       assert !attachment.image?
32       assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
33       assert !attachment.size.zero?
34       #assert_equal 1784, attachment.size
35     end
36   end
37   
38   def test_should_create_thumbnail
39     attachment = upload_file :filename => '/files/rails.png'
40     
41     assert_raise Technoweenie::AttachmentFu::ThumbnailError do
42       attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 50, 50)
43     end
44   end
45   
46   def test_should_create_thumbnail_with_geometry_string
47    attachment = upload_file :filename => '/files/rails.png'
48     
49     assert_raise Technoweenie::AttachmentFu::ThumbnailError do
50       attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 'x50')
51     end
52   end
53 end
54
55 class MinimalAttachmentTest < OrphanAttachmentTest
56   attachment_model MinimalAttachment
57 end

Benjamin Mako Hill || Want to submit a patch?