Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 50 lines (44 sloc) 1.576 kb
f83683b all tests pass
technoweenie authored
1 module BaseAttachmentTests
2 def test_should_create_file_from_uploaded_file
3 assert_created do
4 attachment = upload_file :filename => '/files/foo.txt'
5 assert_valid attachment
6 assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)
7 assert attachment.image?
8 assert !attachment.size.zero?
9 #assert_equal 3, attachment.size
10 assert_nil attachment.width
11 assert_nil attachment.height
12 end
13 end
14
15 def test_reassign_attribute_data
16 assert_created 1 do
17 attachment = upload_file :filename => '/files/rails.png'
18 assert_valid attachment
88f42fb first pass at temp file usage
technoweenie authored
19 assert attachment.size > 0, "no data was set"
f83683b all tests pass
technoweenie authored
20
88f42fb first pass at temp file usage
technoweenie authored
21 attachment.temp_data = 'wtf'
22 assert attachment.save_attachment?
23 attachment.save!
f83683b all tests pass
technoweenie authored
24
d89bfe4 comments comments comments
technoweenie authored
25 assert_equal 'wtf', attachment_model.find(attachment.id).send(:current_data)
f83683b all tests pass
technoweenie authored
26 end
27 end
28
29 def test_no_reassign_attribute_data_on_nil
30 assert_created 1 do
31 attachment = upload_file :filename => '/files/rails.png'
32 assert_valid attachment
88f42fb first pass at temp file usage
technoweenie authored
33 assert attachment.size > 0, "no data was set"
f83683b all tests pass
technoweenie authored
34
88f42fb first pass at temp file usage
technoweenie authored
35 attachment.temp_data = nil
f83683b all tests pass
technoweenie authored
36 assert !attachment.save_attachment?
37 end
38 end
39
40 def test_should_overwrite_old_contents_when_updating
41 attachment = upload_file :filename => '/files/rails.png'
42 assert_not_created do # no new db_file records
88f42fb first pass at temp file usage
technoweenie authored
43 use_temp_file 'files/rails.png' do |file|
44 attachment.filename = 'rails2.png'
1c56f39 small tweaks with tempfile path
technoweenie authored
45 attachment.temp_path = File.join(fixture_path, file)
88f42fb first pass at temp file usage
technoweenie authored
46 attachment.save!
47 end
f83683b all tests pass
technoweenie authored
48 end
49 end
50 end
Something went wrong with that request. Please try again.