Class: OrphanAttachmentTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
BaseAttachmentTests
Defined in:
lib/test/extra_attachment_test.rb

Direct Known Subclasses

MinimalAttachmentTest

Instance Method Summary collapse

Methods included from BaseAttachmentTests

#test_no_reassign_attribute_data_on_nil, #test_reassign_attribute_data, #test_should_overwrite_old_contents_when_updating, #test_should_save_without_updating_file

Instance Method Details

#test_should_create_file_from_uploaded_fileObject



17
18
19
20
21
22
23
24
25
# File 'lib/test/extra_attachment_test.rb', line 17

def test_should_create_file_from_uploaded_file
  assert_created do
    attachment = upload_file :filename => '/files/foo.txt'
    assert_valid attachment
    assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
    assert  attachment.image?
    assert !attachment.size.zero?
  end
end

#test_should_create_image_from_uploaded_fileObject



7
8
9
10
11
12
13
14
15
# File 'lib/test/extra_attachment_test.rb', line 7

def test_should_create_image_from_uploaded_file
  assert_created do
    attachment = upload_file :filename => '/files/rails.png'
    assert_valid attachment
    assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
    assert  attachment.image?
    assert !attachment.size.zero?
  end
end

#test_should_create_image_from_uploaded_file_with_custom_content_typeObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/test/extra_attachment_test.rb', line 27

def test_should_create_image_from_uploaded_file_with_custom_content_type
  assert_created do
    attachment = upload_file :content_type => 'foo/bar', :filename => '/files/rails.png'
    assert_valid attachment
    assert !attachment.image?
    assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
    assert !attachment.size.zero?
    #assert_equal 1784, attachment.size
  end
end

#test_should_create_thumbnailObject



38
39
40
41
42
43
44
# File 'lib/test/extra_attachment_test.rb', line 38

def test_should_create_thumbnail
  attachment = upload_file :filename => '/files/rails.png'
  
  assert_raise Technoweenie::AttachmentFu::ThumbnailError do
    attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 50, 50)
  end
end

#test_should_create_thumbnail_with_geometry_stringObject



46
47
48
49
50
51
52
# File 'lib/test/extra_attachment_test.rb', line 46

def test_should_create_thumbnail_with_geometry_string
 attachment = upload_file :filename => '/files/rails.png'
  
  assert_raise Technoweenie::AttachmentFu::ThumbnailError do
    attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 'x50')
  end
end