diff --git a/test/functional/documents_controller_test.rb b/test/functional/documents_controller_test.rb index d0e586649..8eb741249 100644 --- a/test/functional/documents_controller_test.rb +++ b/test/functional/documents_controller_test.rb @@ -234,6 +234,7 @@ LOREM end def test_destroy + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Document.count', -1 do delete :destroy, :params => { @@ -245,6 +246,7 @@ LOREM end def test_add_attachment + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Attachment.count' do post :add_attachment, :params => { diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index b9ef3bb27..df3756d10 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -348,6 +348,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_index_grouped_by_due_date + set_tmp_attachments_directory Issue.destroy_all Issue.generate!(:due_date => '2018-08-10') Issue.generate!(:due_date => '2018-08-10') @@ -4413,6 +4414,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_create_as_copy_with_attachments_should_also_add_new_files + set_tmp_attachments_directory @request.session[:user_id] = 2 issue = Issue.find(3) count = issue.attachments.count @@ -6672,6 +6674,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issue_with_no_time_entries_should_delete_the_issues + set_tmp_attachments_directory assert_nil TimeEntry.find_by_issue_id(2) @request.session[:user_id] = 2 @@ -6685,6 +6688,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_with_time_entries_should_show_the_reassign_form + set_tmp_attachments_directory @request.session[:user_id] = 2 with_settings :timelog_required_fields => [] do @@ -6705,18 +6709,19 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_with_time_entries_should_not_show_the_nullify_option_when_issue_is_required_for_time_entries + set_tmp_attachments_directory with_settings :timelog_required_fields => ['issue_id'] do @request.session[:user_id] = 2 - assert_no_difference 'Issue.count' do - delete :destroy, :params => { - :ids => [1, 3] - } - end - assert_response :success + assert_no_difference 'Issue.count' do + delete :destroy, :params => { + :ids => [1, 3] + } + end + assert_response :success - assert_select 'form' do - assert_select 'input[name=_method][value=delete]' + assert_select 'form' do + assert_select 'input[name=_method][value=delete]' assert_select 'input[name=todo][value=destroy]' assert_select 'input[name=todo][value=nullify]', 0 assert_select 'input[name=todo][value=reassign]' @@ -6741,6 +6746,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_and_destroy_time_entries + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Issue.count', -2 do @@ -6757,6 +6763,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_and_assign_time_entries_to_project + set_tmp_attachments_directory @request.session[:user_id] = 2 with_settings :timelog_required_fields => [] do @@ -6776,6 +6783,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_and_reassign_time_entries_to_another_issue + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Issue.count', -2 do @@ -6816,6 +6824,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_no_difference 'Issue.count' do @@ -6832,6 +6841,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_and_reassign_time_entries_to_an_issue_to_delete_should_fail + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_no_difference 'Issue.count' do @@ -6848,6 +6858,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_and_nullify_time_entries_should_fail_when_issue_is_required_for_time_entries + set_tmp_attachments_directory @request.session[:user_id] = 2 with_settings :timelog_required_fields => ['issue_id'] do @@ -6865,6 +6876,7 @@ class IssuesControllerTest < Redmine::ControllerTest end def test_destroy_issues_from_different_projects + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Issue.count', -3 do diff --git a/test/functional/journals_controller_test.rb b/test/functional/journals_controller_test.rb index b003a3659..b5df9cffa 100644 --- a/test/functional/journals_controller_test.rb +++ b/test/functional/journals_controller_test.rb @@ -62,6 +62,7 @@ class JournalsControllerTest < Redmine::ControllerTest end def test_index_should_show_visible_custom_fields_only + set_tmp_attachments_directory Issue.destroy_all Journal.delete_all field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all} diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index 64c70157b..ad193b119 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -232,6 +232,7 @@ class MessagesControllerTest < Redmine::ControllerTest end def test_destroy_topic + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Message.count', -3 do post :destroy, :params => { diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 63159ab90..cd1476a76 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -834,6 +834,7 @@ class ProjectsControllerTest < Redmine::ControllerTest end def test_destroy_without_confirmation_should_show_confirmation_with_subprojects + set_tmp_attachments_directory @request.session[:user_id] = 1 # admin assert_no_difference 'Project.count' do @@ -849,6 +850,7 @@ class ProjectsControllerTest < Redmine::ControllerTest end def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects + set_tmp_attachments_directory @request.session[:user_id] = 1 # admin assert_difference 'Project.count', -5 do diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 6ee3bff51..7d36ea3f2 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -273,6 +273,7 @@ class WikiControllerTest < Redmine::ControllerTest end def test_create_page_with_attachments + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'WikiPage.count' do assert_difference 'Attachment.count' do @@ -443,6 +444,7 @@ class WikiControllerTest < Redmine::ControllerTest end def test_update_page_with_attachments_only_should_not_create_content_version + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_no_difference 'WikiPage.count' do assert_no_difference 'WikiContent.count' do @@ -1179,6 +1181,7 @@ class WikiControllerTest < Redmine::ControllerTest end def test_add_attachment + set_tmp_attachments_directory @request.session[:user_id] = 2 assert_difference 'Attachment.count' do post :add_attachment, :params => { diff --git a/test/functional/wikis_controller_test.rb b/test/functional/wikis_controller_test.rb index 5b53aaae8..fad3d8365 100644 --- a/test/functional/wikis_controller_test.rb +++ b/test/functional/wikis_controller_test.rb @@ -27,6 +27,7 @@ class WikisControllerTest < Redmine::ControllerTest end def test_get_destroy_should_ask_confirmation + set_tmp_attachments_directory @request.session[:user_id] = 1 assert_no_difference 'Wiki.count' do get :destroy, :params => {:id => 1} @@ -35,6 +36,7 @@ class WikisControllerTest < Redmine::ControllerTest end def test_post_destroy_should_delete_wiki + set_tmp_attachments_directory @request.session[:user_id] = 1 post :destroy, :params => {:id => 1, :confirm => 1} assert_redirected_to :controller => 'projects', diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 9abf47fa7..552eb210f 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -190,7 +190,6 @@ RAW end def test_attached_images_filename_extension - set_tmp_attachments_directory a1 = Attachment.new( :container => Issue.find(1), :file => mock_file_with_options({:original_filename => "testtest.JPG"}), @@ -264,6 +263,7 @@ RAW } attachments = [a1, a2] to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text, :attachments => attachments) } + ensure set_tmp_attachments_directory end @@ -722,7 +722,6 @@ RAW end def test_attachment_link_should_link_to_latest_attachment - set_tmp_attachments_directory a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago) a2 = Attachment.generate!(:filename => "test.txt") result = link_to("test.txt", "/attachments/#{a2.id}", diff --git a/test/helpers/journals_helper_test.rb b/test/helpers/journals_helper_test.rb index 2e54a2a29..bda4945f9 100644 --- a/test/helpers/journals_helper_test.rb +++ b/test/helpers/journals_helper_test.rb @@ -32,6 +32,7 @@ class JournalsHelperTest < Redmine::HelperTest :versions def test_journal_thumbnail_attachments_should_return_thumbnailable_attachments + set_tmp_attachments_directory issue = Issue.generate! journal = new_record(Journal) do diff --git a/test/integration/attachments_test.rb b/test/integration/attachments_test.rb index 0e6336998..de5bca57f 100644 --- a/test/integration/attachments_test.rb +++ b/test/integration/attachments_test.rb @@ -152,7 +152,6 @@ class AttachmentsTest < Redmine::IntegrationTest get "/attachments/download/4" assert_response :success assert_not_nil response.headers["X-Sendfile"] - ensure set_tmp_attachments_directory end diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb index 28eccedbc..3cbe61840 100644 --- a/test/system/issues_test.rb +++ b/test/system/issues_test.rb @@ -149,8 +149,6 @@ class IssuesTest < ApplicationSystemTestCase end assert_equal 1, issue.attachments.count assert_equal 'Some description', issue.attachments.first.description - ensure - set_fixtures_attachments_directory end def test_create_issue_with_new_target_version diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb index 2605f03f0..fbbe71fbe 100644 --- a/test/unit/attachment_test.rb +++ b/test/unit/attachment_test.rb @@ -344,6 +344,8 @@ class AttachmentTest < ActiveSupport::TestCase assert attachment.readable? attachment.update_digest_to_sha256! assert_equal 'ac5c6e99a21ae74b2e3f5b8e5b568be1b9107cd7153d139e822b9fe5caf50938', attachment.digest + ensure + set_tmp_attachments_directory end def test_update_attachments @@ -403,7 +405,7 @@ class AttachmentTest < ActiveSupport::TestCase assert_equal 17, la1.id la2 = Attachment.latest_attach([a1, a2], "Testfile.PNG") assert_equal 17, la2.id - + ensure set_tmp_attachments_directory end @@ -444,6 +446,8 @@ class AttachmentTest < ActiveSupport::TestCase assert File.exist?(thumbnail) end end + ensure + set_tmp_attachments_directory end def test_should_reuse_thumbnail @@ -490,6 +494,8 @@ class AttachmentTest < ActiveSupport::TestCase set_fixtures_attachments_directory attachment = Attachment.find(16) assert_nil attachment.thumbnail + ensure + set_tmp_attachments_directory end def test_thumbnail_should_be_at_least_of_requested_size @@ -508,6 +514,8 @@ class AttachmentTest < ActiveSupport::TestCase assert_equal "8e0294de2441577c529f170b6fb8f638_2654_#{generated_size}.thumb", File.basename(thumbnail) end + ensure + set_tmp_attachments_directory end else puts '(ImageMagick convert not available)' diff --git a/test/unit/board_test.rb b/test/unit/board_test.rb index 3f7679320..52cc37779 100644 --- a/test/unit/board_test.rb +++ b/test/unit/board_test.rb @@ -93,6 +93,7 @@ class BoardTest < ActiveSupport::TestCase end def test_destroy + set_tmp_attachments_directory board = Board.find(1) assert_difference 'Message.count', -6 do assert_difference 'Attachment.count', -1 do diff --git a/test/unit/lib/redmine/export/pdf_test.rb b/test/unit/lib/redmine/export/pdf_test.rb index 095dcfb55..3bad1d8d9 100644 --- a/test/unit/lib/redmine/export/pdf_test.rb +++ b/test/unit/lib/redmine/export/pdf_test.rb @@ -69,9 +69,8 @@ class PdfTest < ActiveSupport::TestCase end def test_attach + set_fixtures_attachments_directory ["CP932", "SJIS"].each do |encoding| - set_fixtures_attachments_directory - str2 = "\x83e\x83X\x83g".b a1 = Attachment.find(17) @@ -99,8 +98,8 @@ class PdfTest < ActiveSupport::TestCase assert_nil aa1 aa2 = Redmine::Export::PDF::RDMPdfEncoding::attach(Attachment.all, "test#{str2}.png", encoding) assert_nil aa2 - - set_tmp_attachments_directory end + ensure + set_tmp_attachments_directory end end diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 8d7b022b9..0a0867a6f 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -542,6 +542,7 @@ class MailHandlerTest < ActiveSupport::TestCase end def test_add_issue_from_apple_mail + set_tmp_attachments_directory issue = submit_email( 'apple_mail_with_attachment.eml', :issue => {:project => 'ecookbook'} @@ -558,6 +559,7 @@ class MailHandlerTest < ActiveSupport::TestCase end def test_thunderbird_with_attachment_ja + set_tmp_attachments_directory issue = submit_email( 'thunderbird_with_attachment_ja.eml', :issue => {:project => 'ecookbook'} @@ -582,6 +584,7 @@ class MailHandlerTest < ActiveSupport::TestCase end def test_gmail_with_attachment_ja + set_tmp_attachments_directory issue = submit_email( 'gmail_with_attachment_ja.eml', :issue => {:project => 'ecookbook'} @@ -597,6 +600,7 @@ class MailHandlerTest < ActiveSupport::TestCase end def test_thunderbird_with_attachment_latin1 + set_tmp_attachments_directory issue = submit_email( 'thunderbird_with_attachment_iso-8859-1.eml', :issue => {:project => 'ecookbook'} @@ -615,6 +619,7 @@ class MailHandlerTest < ActiveSupport::TestCase end def test_gmail_with_attachment_latin1 + set_tmp_attachments_directory issue = submit_email( 'gmail_with_attachment_iso-8859-1.eml', :issue => {:project => 'ecookbook'} @@ -633,6 +638,7 @@ class MailHandlerTest < ActiveSupport::TestCase end def test_mail_with_attachment_latin2 + set_tmp_attachments_directory issue = submit_email( 'ticket_with_text_attachment_iso-8859-2.eml', :issue => {:project => 'ecookbook'} @@ -986,6 +992,7 @@ class MailHandlerTest < ActiveSupport::TestCase end def test_reply_to_a_nonexistent_issue + set_tmp_attachments_directory Issue.find(2).destroy assert_no_difference 'Issue.count' do assert_no_difference 'Journal.count' do diff --git a/test/unit/message_test.rb b/test/unit/message_test.rb index 5bbb2190c..e714e09ae 100644 --- a/test/unit/message_test.rb +++ b/test/unit/message_test.rb @@ -108,6 +108,7 @@ class MessageTest < ActiveSupport::TestCase end def test_destroy_topic + set_tmp_attachments_directory message = Message.find(1) board = message.board topics_count, messages_count = board.topics_count, board.messages_count diff --git a/test/unit/project_copy_test.rb b/test/unit/project_copy_test.rb index fb07d6b65..eac3aa8bf 100644 --- a/test/unit/project_copy_test.rb +++ b/test/unit/project_copy_test.rb @@ -55,6 +55,7 @@ class ProjectCopyTest < ActiveSupport::TestCase end test "#copy should copy project attachments" do + set_tmp_attachments_directory Attachment.create!(:container => @source_project, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1) assert @project.copy(@source_project) @@ -207,6 +208,7 @@ class ProjectCopyTest < ActiveSupport::TestCase end test "#copy should copy issue attachments" do + set_tmp_attachments_directory issue = Issue.generate!(:subject => "copy with attachment", :tracker_id => 1, :project_id => @source_project.id) Attachment.create!(:container => issue, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1) @source_project.issues << issue @@ -296,6 +298,7 @@ class ProjectCopyTest < ActiveSupport::TestCase end test "#copy should copy version attachments" do + set_tmp_attachments_directory version = Version.generate!(:name => "copy with attachment") Attachment.create!(:container => version, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1) @source_project.versions << version @@ -378,6 +381,7 @@ class ProjectCopyTest < ActiveSupport::TestCase end test "#copy should copy document attachments" do + set_tmp_attachments_directory document = Document.generate!(:title => "copy with attachment", :category_id => 1, :project_id => @source_project.id) Attachment.create!(:container => document, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1) @source_project.documents << document diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 519de8b04..da9fbe7ed 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -262,6 +262,7 @@ class UserTest < ActiveSupport::TestCase end def test_destroy_should_update_attachments + set_tmp_attachments_directory attachment = Attachment.create!(:container => Project.find(1), :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2) diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb index f3fe4fbbd..6092e3fd5 100644 --- a/test/unit/wiki_page_test.rb +++ b/test/unit/wiki_page_test.rb @@ -143,6 +143,7 @@ class WikiPageTest < ActiveSupport::TestCase end def test_destroy_should_delete_content_and_its_versions + set_tmp_attachments_directory page = WikiPage.find(1) assert_difference 'WikiPage.count', -1 do assert_difference 'WikiContent.count', -1 do diff --git a/test/unit/wiki_test.rb b/test/unit/wiki_test.rb index b4ecd29bb..d4688569d 100644 --- a/test/unit/wiki_test.rb +++ b/test/unit/wiki_test.rb @@ -103,6 +103,7 @@ class WikiTest < ActiveSupport::TestCase end def test_destroy_should_remove_redirects_from_the_wiki + set_tmp_attachments_directory WikiRedirect.create!(:wiki_id => 1, :title => 'Foo', :redirects_to_wiki_id => 2, :redirects_to => 'Bar') Wiki.find(1).destroy @@ -110,6 +111,7 @@ class WikiTest < ActiveSupport::TestCase end def test_destroy_should_remove_redirects_to_the_wiki + set_tmp_attachments_directory WikiRedirect.create!(:wiki_id => 2, :title => 'Foo', :redirects_to_wiki_id => 1, :redirects_to => 'Bar') Wiki.find(1).destroy