summaryrefslogtreecommitdiffstats
path: root/test/functional/wiki_controller_test.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2018-07-25 14:35:18 +0000
committerGo MAEDA <maeda@farend.jp>2018-07-25 14:35:18 +0000
commit399a66a9a9020563c22bf62f534e0a439bedd830 (patch)
treee0077c53e3a765bd7a5a959f3e7ab35a50b4690e /test/functional/wiki_controller_test.rb
parent81fcc06d55917d5d4548a03688caa3e30699a52d (diff)
downloadredmine-399a66a9a9020563c22bf62f534e0a439bedd830.tar.gz
redmine-399a66a9a9020563c22bf62f534e0a439bedd830.zip
Bulk delete wiki attachments (#16410).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@17453 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/wiki_controller_test.rb')
-rw-r--r--test/functional/wiki_controller_test.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index c0a169d7b..0583882e1 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -459,6 +459,44 @@ class WikiControllerTest < Redmine::ControllerTest
assert_equal 1, page.content.version
end
+ def test_update_with_deleted_attachment_ids
+ @request.session[:user_id] = 2
+ page = WikiPage.find(4)
+ attachment = page.attachments.first
+ assert_difference 'Attachment.count', -1 do
+ put :update, :params => {
+ :project_id => page.wiki.project.id,
+ :id => page.title,
+ :content => {
+ :comments => 'delete file',
+ :text => 'edited'
+ },
+ :wiki_page => {:deleted_attachment_ids => [attachment.id]}
+ }
+ end
+ page.reload
+ refute_includes page.attachments, attachment
+ end
+
+ def test_update_with_deleted_attachment_ids_and_failure_should_preserve_selected_attachments
+ @request.session[:user_id] = 2
+ page = WikiPage.find(4)
+ attachment = page.attachments.first
+ assert_no_difference 'Attachment.count' do
+ put :update, :params => {
+ :project_id => page.wiki.project.id,
+ :id => page.title,
+ :content => {
+ :comments => 'a' * 1300, # failure here, comment is too long
+ :text => 'edited'
+ },
+ :wiki_page => {:deleted_attachment_ids => [attachment.id]}
+ }
+ end
+ page.reload
+ assert_includes page.attachments, attachment
+ end
+
def test_update_stale_page_should_not_raise_an_error
@request.session[:user_id] = 2
c = Wiki.find(1).find_page('Another_page').content