Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 67 lines (57 sloc) 2.268 kb
f83683b all tests pass
technoweenie authored
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
3836c31 @redinger Work with merb tempfile
redinger authored
27 def test_should_create_file_from_merb_temp_file
28 assert_created do
29 attachment = upload_merb_file :filename => '/files/foo.txt'
30 assert_valid attachment
31 assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
32 assert attachment.image?
33 assert !attachment.size.zero?
34 end
35 end
36
f83683b all tests pass
technoweenie authored
37 def test_should_create_image_from_uploaded_file_with_custom_content_type
38 assert_created do
39 attachment = upload_file :content_type => 'foo/bar', :filename => '/files/rails.png'
40 assert_valid attachment
41 assert !attachment.image?
42 assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
43 assert !attachment.size.zero?
44 #assert_equal 1784, attachment.size
45 end
46 end
47
48 def test_should_create_thumbnail
49 attachment = upload_file :filename => '/files/rails.png'
50
51 assert_raise Technoweenie::AttachmentFu::ThumbnailError do
79f2913 huzzah, the tempfile tests pass.
technoweenie authored
52 attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 50, 50)
f83683b all tests pass
technoweenie authored
53 end
54 end
55
56 def test_should_create_thumbnail_with_geometry_string
57 attachment = upload_file :filename => '/files/rails.png'
58
59 assert_raise Technoweenie::AttachmentFu::ThumbnailError do
79f2913 huzzah, the tempfile tests pass.
technoweenie authored
60 attachment.create_or_update_thumbnail(attachment.create_temp_file, 'thumb', 'x50')
f83683b all tests pass
technoweenie authored
61 end
62 end
63 end
64
65 class MinimalAttachmentTest < OrphanAttachmentTest
66 attachment_model MinimalAttachment
67 end
Something went wrong with that request. Please try again.