Module: BaseAttachmentTests
- Included in:
- DbFileTest, FileSystemTest, OrphanAttachmentTest, S3Test
- Defined in:
- lib/test/base_attachment_tests.rb
Instance Method Summary collapse
- #test_no_reassign_attribute_data_on_nil ⇒ Object
- #test_reassign_attribute_data ⇒ Object
- #test_should_create_file_from_uploaded_file ⇒ Object
- #test_should_overwrite_old_contents_when_updating ⇒ Object
- #test_should_save_without_updating_file ⇒ Object
Instance Method Details
#test_no_reassign_attribute_data_on_nil ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/test/base_attachment_tests.rb', line 29 def test_no_reassign_attribute_data_on_nil assert_created 1 do = upload_file :filename => '/files/rails.png' assert_valid assert .size > 0, "no data was set" .temp_data = nil assert !. end end |
#test_reassign_attribute_data ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/test/base_attachment_tests.rb', line 15 def test_reassign_attribute_data assert_created 1 do = upload_file :filename => '/files/rails.png' assert_valid assert .size > 0, "no data was set" .temp_data = 'wtf' assert . .save! assert_equal 'wtf', .find(.id).send(:current_data) end end |
#test_should_create_file_from_uploaded_file ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/test/base_attachment_tests.rb', line 2 def test_should_create_file_from_uploaded_file assert_created do = upload_file :filename => '/files/foo.txt' assert_valid assert !.db_file.new_record? if .respond_to?(:db_file) assert .image? assert !.size.zero? #assert_equal 3, attachment.size assert_nil .width assert_nil .height end end |
#test_should_overwrite_old_contents_when_updating ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/test/base_attachment_tests.rb', line 40 def test_should_overwrite_old_contents_when_updating = upload_file :filename => '/files/rails.png' assert_not_created do # no new db_file records use_temp_file 'files/rails.png' do |file| .filename = 'rails2.png' .temp_path = File.join(fixture_path, file) .save! end end end |
#test_should_save_without_updating_file ⇒ Object
51 52 53 54 55 56 |
# File 'lib/test/base_attachment_tests.rb', line 51 def test_should_save_without_updating_file = upload_file :filename => '/files/foo.txt' assert_valid assert !. assert_nothing_raised { .save! } end |