diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-06-19 03:54:17 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-06-19 03:54:17 +0000 |
commit | c56c0f411c577fe17b64fe33875cad5d75e34284 (patch) | |
tree | 69c1c52d5e8b8f70da2b7656333c7cb7bac6a564 /test/unit/attachment_test.rb | |
parent | 759858d11d0c819d188efc4540960513dd3027dc (diff) | |
download | redmine-c56c0f411c577fe17b64fe33875cad5d75e34284.tar.gz redmine-c56c0f411c577fe17b64fe33875cad5d75e34284.zip |
Fix a nil error when a Project cannot save attachments.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3772 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/attachment_test.rb')
-rw-r--r-- | test/unit/attachment_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 7c6a9b4b1..f04aca4d4 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -63,4 +63,30 @@ class AttachmentTest < ActiveSupport::TestCase assert_equal 'f8139524ebb8f32e51976982cd20a85d', Attachment.disk_filename("test_accentué")[13..-1] assert_equal 'cbb5b0f30978ba03731d61f9f6d10011', Attachment.disk_filename("test_accentué.ça")[13..-1] end + + context "Attachmnet#attach_files" do + should "add unsaved files to the object as unsaved attachments" do + # Max size of 0 to force Attachment creation failures + with_settings(:attachment_max_size => 0) do + # Mock out a file + @file = 'a_file.png' + @file.stubs(:size).returns(32) + @file.stubs(:original_filename).returns('a_file.png') + @file.stubs(:content_type).returns('image/png') + @file.stubs(:read).returns(false) + + @project = Project.generate! + response = Attachment.attach_files(@project, { + '1' => {'file' => @file, 'description' => 'test'}, + '2' => {'file' => @file, 'description' => 'test'} + }) + + assert response[:unsaved].present? + assert_equal 2, response[:unsaved].length + assert response[:unsaved].first.new_record? + assert response[:unsaved].second.new_record? + assert_equal response[:unsaved], @project.unsaved_attachments + end + end + end end |