]> source.dussan.org Git - redmine.git/commitdiff
Fix test failure due to missing call to set_tmp_attachments_directory (#32122).
authorGo MAEDA <maeda@farend.jp>
Fri, 4 Oct 2019 11:17:33 +0000 (11:17 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 4 Oct 2019 11:17:33 +0000 (11:17 +0000)
Patch by Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@18593 e93f8b46-1217-0410-a6f0-8f06a7374b81

20 files changed:
test/functional/documents_controller_test.rb
test/functional/issues_controller_test.rb
test/functional/journals_controller_test.rb
test/functional/messages_controller_test.rb
test/functional/projects_controller_test.rb
test/functional/wiki_controller_test.rb
test/functional/wikis_controller_test.rb
test/helpers/application_helper_test.rb
test/helpers/journals_helper_test.rb
test/integration/attachments_test.rb
test/system/issues_test.rb
test/unit/attachment_test.rb
test/unit/board_test.rb
test/unit/lib/redmine/export/pdf_test.rb
test/unit/mail_handler_test.rb
test/unit/message_test.rb
test/unit/project_copy_test.rb
test/unit/user_test.rb
test/unit/wiki_page_test.rb
test/unit/wiki_test.rb

index d0e586649ec5c20b6aa18666a72ad4dd58052282..8eb74124908a746410525abc001b2077542bfa67 100644 (file)
@@ -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 => {
index adbe6b794df49fbefd8625616f8898a22c77fdf5..6f9ff1dfa74708b3e6478b23ef738b0b58d8a2f6 100644 (file)
@@ -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
@@ -6670,6 +6672,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
 
@@ -6683,6 +6686,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
@@ -6703,18 +6707,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]'
@@ -6739,6 +6744,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
@@ -6755,6 +6761,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
@@ -6774,6 +6781,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
@@ -6814,6 +6822,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
@@ -6830,6 +6839,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
@@ -6846,6 +6856,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
@@ -6863,6 +6874,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
index b003a365988263266605e28120ffa613b6bb9d6a..b5df9cffa772e71dff18cc7ca2c4deb53fe4f513 100644 (file)
@@ -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}
index 64c70157bd4ad539768c12e5cfeff1d9d3df6d6a..ad193b119b5d23e413dc939f1a16fb46ac93047c 100644 (file)
@@ -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 => {
index 63159ab90f2bed9da7c6de5f881f68314a53a9b1..cd1476a76094ca8d9c81255c8fbb74ab72549cf9 100644 (file)
@@ -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
index 6ee3bff51058e20275b4e4c5ee9431ed59ea32a7..7d36ea3f232e50ce1bb42e107bf77849a58ebf8b 100644 (file)
@@ -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 => {
index 5b53aaae8fde2b6ed5433578771827bafd0050f8..fad3d8365f3c77995567a0b0ab80e9cf82a2e0cb 100644 (file)
@@ -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',
index 9abf47fa768236a668f469c03d08d7603c396e8f..552eb210f8eb2e440d30cc45ad1343f0a26c06ee 100644 (file)
@@ -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 "<p>#{result}</p>", 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}",
index 2e54a2a292f96f1ef68fae492be45dbcd30a4328..bda4945f9b27a8874c0ad8bb2527787e86151c40 100644 (file)
@@ -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
index 0e6336998f2475c49c976aa91676bb030089383a..de5bca57f79fc39d76455b3d557ea9a97ee85121 100644 (file)
@@ -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
index 3f3edf4b5feccddce358e18f3dedfadf819f6297..bfb75d11ba3345c90f9e92a7b28fd385ebcb01d2 100644 (file)
@@ -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
index 2605f03f015927443c669b4d02ab307b122c5bda..fbbe71fbecd77856105ad792653181c53dc7429e 100644 (file)
@@ -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)'
index 3f767932025b06e2e6db7c0fba5b3e4efc5b64d7..52cc37779f5acee25d162154c3cc7a59553eebeb 100644 (file)
@@ -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
index 095dcfb559d5f8174c99bbe0cad2187e8cae90a1..3bad1d8d980e20dd8ae34dab6d40825aa9f0ff6e 100644 (file)
@@ -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
index 51a07aeecd33f0940229b3c3b90a62e3d396897d..e3c527fa173620fd5c3c155d90d39c39e24ba987 100644 (file)
@@ -543,6 +543,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'}
@@ -559,6 +560,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'}
@@ -583,6 +585,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'}
@@ -598,6 +601,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'}
@@ -616,6 +620,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'}
@@ -634,6 +639,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'}
@@ -987,6 +993,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
index 5bbb2190c313a4e0de5aeb98251289d71f03ee19..e714e09ae93d4bb9c0ddeac078cdc33f8e6ffafd 100644 (file)
@@ -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
index af56c15a9b262b8bb1dcda980ee70a03a2a84baf..e121dcc167f4ed3dc803caeade8d954b7d328813 100644 (file)
@@ -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
index 519de8b042db95d37c0b1c6eb415600a6cf358af..da9fbe7edd4ea504e198b5730fad3af7181db86a 100644 (file)
@@ -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)
index f3fe4fbbdc4cfb51425ce0fff731564d953378e7..6092e3fd51f9e3a31666a023d2a2fb6d4a0f0f05 100644 (file)
@@ -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
index b4ecd29bbbbb1cc365f9f21fc26cbc52275222ad..d4688569dde93918344aee80ef074da69e599550 100644 (file)
@@ -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