summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-03-03 17:04:55 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-03-03 17:04:55 +0000
commit44955a519c77abe09e9706135a0443761604c780 (patch)
tree87fe12e7df2d482b215e8bdf2f8d8a1d4cf802ab
parentf6d8752e442cf1b4fa7c5004c86b9597ff8e94b1 (diff)
downloadredmine-44955a519c77abe09e9706135a0443761604c780.tar.gz
redmine-44955a519c77abe09e9706135a0443761604c780.zip
Added test for when an attachment fails to save.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3527 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--test/functional/issues_controller_test.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 650a06eae..32b4e7d00 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -808,7 +808,27 @@ class IssuesControllerTest < ActionController::TestCase
mail = ActionMailer::Base.deliveries.last
assert mail.body.include?('testfile.txt')
end
-
+
+ def test_put_update_with_attachment_that_fails_to_save
+ set_tmp_attachments_directory
+
+ # Delete all fixtured journals, a race condition can occur causing the wrong
+ # journal to get fetched in the next find.
+ Journal.delete_all
+
+ # Mock out the unsaved attachment
+ Attachment.any_instance.stubs(:create).returns(Attachment.new)
+
+ # anonymous user
+ put :update,
+ :id => 1,
+ :notes => '',
+ :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}}
+ assert_redirected_to :action => 'show', :id => '1'
+ assert_equal '1 file(s) could not be saved.', flash[:warning]
+
+ end if Object.const_defined?(:Mocha)
+
def test_put_update_with_no_change
issue = Issue.find(1)
issue.journals.clear