1 require File.expand_path(File.join(File.dirname(__FILE__), 'test_helper'))
3 class OrphanAttachmentTest < Test::Unit::TestCase
4 include BaseAttachmentTests
5 attachment_model OrphanAttachment
7 def test_should_create_image_from_uploaded_file
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?
17 def test_should_create_file_from_uploaded_file
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?
27 def test_should_create_image_from_uploaded_file_with_custom_content_type
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
38 def test_should_create_thumbnail
39 attachment = upload_file :filename => '/files/rails.png'
41 assert_raise Technoweenie::AttachmentFu::ThumbnailError do
42 attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 50, 50)
46 def test_should_create_thumbnail_with_geometry_string
47 attachment = upload_file :filename => '/files/rails.png'
49 assert_raise Technoweenie::AttachmentFu::ThumbnailError do
50 attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 'x50')
55 class MinimalAttachmentTest < OrphanAttachmentTest
56 attachment_model MinimalAttachment