diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-12-09 16:54:46 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-12-09 16:54:46 +0000 |
commit | 5d2899ee1b3e00d0cf43521182b1244dfc3cfe9f (patch) | |
tree | eb64711c0150fafb698da9d92eb0d6735a5461cf /test | |
parent | 2b6e332318a3e0a9489d20280010bb2d00206d95 (diff) | |
download | redmine-5d2899ee1b3e00d0cf43521182b1244dfc3cfe9f.tar.gz redmine-5d2899ee1b3e00d0cf43521182b1244dfc3cfe9f.zip |
AttachmentsController now handles attachments deletion.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2116 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/attachments_controller_test.rb | 29 | ||||
-rw-r--r-- | test/functional/issues_controller_test.rb | 13 | ||||
-rw-r--r-- | test/functional/wiki_controller_test.rb | 7 |
3 files changed, 29 insertions, 20 deletions
diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 139896ce6..e566f2c4b 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -76,4 +76,33 @@ class AttachmentsControllerTest < Test::Unit::TestCase get :download, :id => 7 assert_redirected_to 'account/login' end + + def test_destroy_issue_attachment + issue = Issue.find(3) + @request.session[:user_id] = 2 + + assert_difference 'issue.attachments.count', -1 do + post :destroy, :id => 1 + end + # no referrer + assert_redirected_to 'projects/show/ecookbook' + assert_nil Attachment.find_by_id(1) + j = issue.journals.find(:first, :order => 'created_on DESC') + assert_equal 'attachment', j.details.first.property + assert_equal '1', j.details.first.prop_key + assert_equal 'error281.txt', j.details.first.old_value + end + + def test_destroy_wiki_page_attachment + @request.session[:user_id] = 2 + assert_difference 'Attachment.count', -1 do + post :destroy, :id => 3 + end + end + + def test_destroy_without_permission + post :destroy, :id => 3 + assert_redirected_to '/login' + assert Attachment.find_by_id(3) + end end diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 8bd1af565..86340ba63 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -713,17 +713,4 @@ class IssuesControllerTest < Test::Unit::TestCase assert_equal 2, TimeEntry.find(1).issue_id assert_equal 2, TimeEntry.find(2).issue_id end - - def test_destroy_attachment - issue = Issue.find(3) - a = issue.attachments.size - @request.session[:user_id] = 2 - post :destroy_attachment, :id => 3, :attachment_id => 1 - assert_redirected_to 'issues/show/3' - assert_nil Attachment.find_by_id(1) - issue.reload - assert_equal((a-1), issue.attachments.size) - j = issue.journals.find(:first, :order => 'created_on DESC') - assert_equal 'attachment', j.details.first.property - end end diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 053b86301..b5325357c 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -251,11 +251,4 @@ class WikiControllerTest < Test::Unit::TestCase assert_response :success assert_template 'edit' end - - def test_destroy_attachment - @request.session[:user_id] = 2 - assert_difference 'Attachment.count', -1 do - post :destroy_attachment, :id => 1, :page => 'Page_with_an_inline_image', :attachment_id => 3 - end - end end |