Project

General

Profile

Patch #32122 ยป add_call_to_set_tmp_attachments_directory.patch

Yuichi HARADA, 2019-09-24 03:53

View differences:

test/functional/documents_controller_test.rb
234 234
  end
235 235

  
236 236
  def test_destroy
237
    set_tmp_attachments_directory
237 238
    @request.session[:user_id] = 2
238 239
    assert_difference 'Document.count', -1 do
239 240
      delete :destroy, :params => {
......
245 246
  end
246 247

  
247 248
  def test_add_attachment
249
    set_tmp_attachments_directory
248 250
    @request.session[:user_id] = 2
249 251
    assert_difference 'Attachment.count' do
250 252
      post :add_attachment, :params => {
test/functional/issues_controller_test.rb
348 348
  end
349 349

  
350 350
  def test_index_grouped_by_due_date
351
    set_tmp_attachments_directory
351 352
    Issue.destroy_all
352 353
    Issue.generate!(:due_date => '2018-08-10')
353 354
    Issue.generate!(:due_date => '2018-08-10')
......
4413 4414
  end
4414 4415

  
4415 4416
  def test_create_as_copy_with_attachments_should_also_add_new_files
4417
    set_tmp_attachments_directory
4416 4418
    @request.session[:user_id] = 2
4417 4419
    issue = Issue.find(3)
4418 4420
    count = issue.attachments.count
......
6672 6674
  end
6673 6675

  
6674 6676
  def test_destroy_issue_with_no_time_entries_should_delete_the_issues
6677
    set_tmp_attachments_directory
6675 6678
    assert_nil TimeEntry.find_by_issue_id(2)
6676 6679
    @request.session[:user_id] = 2
6677 6680

  
......
6685 6688
  end
6686 6689

  
6687 6690
  def test_destroy_issues_with_time_entries_should_show_the_reassign_form
6691
    set_tmp_attachments_directory
6688 6692
    @request.session[:user_id] = 2
6689 6693

  
6690 6694
    with_settings :timelog_required_fields => [] do
......
6705 6709
  end
6706 6710

  
6707 6711
  def test_destroy_issues_with_time_entries_should_not_show_the_nullify_option_when_issue_is_required_for_time_entries
6712
    set_tmp_attachments_directory
6708 6713
    with_settings :timelog_required_fields => ['issue_id'] do
6709 6714
      @request.session[:user_id] = 2
6710 6715

  
6711
    assert_no_difference 'Issue.count' do
6712
      delete :destroy, :params => {
6713
          :ids => [1, 3]
6714
        }
6715
    end
6716
    assert_response :success
6716
      assert_no_difference 'Issue.count' do
6717
        delete :destroy, :params => {
6718
            :ids => [1, 3]
6719
          }
6720
      end
6721
      assert_response :success
6717 6722

  
6718
    assert_select 'form' do
6719
      assert_select 'input[name=_method][value=delete]'
6723
      assert_select 'form' do
6724
        assert_select 'input[name=_method][value=delete]'
6720 6725
        assert_select 'input[name=todo][value=destroy]'
6721 6726
        assert_select 'input[name=todo][value=nullify]', 0
6722 6727
        assert_select 'input[name=todo][value=reassign]'
......
6741 6746
  end
6742 6747

  
6743 6748
  def test_destroy_issues_and_destroy_time_entries
6749
    set_tmp_attachments_directory
6744 6750
    @request.session[:user_id] = 2
6745 6751

  
6746 6752
    assert_difference 'Issue.count', -2 do
......
6757 6763
  end
6758 6764

  
6759 6765
  def test_destroy_issues_and_assign_time_entries_to_project
6766
    set_tmp_attachments_directory
6760 6767
    @request.session[:user_id] = 2
6761 6768

  
6762 6769
    with_settings :timelog_required_fields => [] do
......
6776 6783
  end
6777 6784

  
6778 6785
  def test_destroy_issues_and_reassign_time_entries_to_another_issue
6786
    set_tmp_attachments_directory
6779 6787
    @request.session[:user_id] = 2
6780 6788

  
6781 6789
    assert_difference 'Issue.count', -2 do
......
6816 6824
  end
6817 6825

  
6818 6826
  def test_destroy_issues_and_reassign_time_entries_to_an_invalid_issue_should_fail
6827
    set_tmp_attachments_directory
6819 6828
    @request.session[:user_id] = 2
6820 6829

  
6821 6830
    assert_no_difference 'Issue.count' do
......
6832 6841
  end
6833 6842

  
6834 6843
  def test_destroy_issues_and_reassign_time_entries_to_an_issue_to_delete_should_fail
6844
    set_tmp_attachments_directory
6835 6845
    @request.session[:user_id] = 2
6836 6846

  
6837 6847
    assert_no_difference 'Issue.count' do
......
6848 6858
  end
6849 6859

  
6850 6860
  def test_destroy_issues_and_nullify_time_entries_should_fail_when_issue_is_required_for_time_entries
6861
    set_tmp_attachments_directory
6851 6862
    @request.session[:user_id] = 2
6852 6863

  
6853 6864
    with_settings :timelog_required_fields => ['issue_id'] do
......
6865 6876
  end
6866 6877

  
6867 6878
  def test_destroy_issues_from_different_projects
6879
    set_tmp_attachments_directory
6868 6880
    @request.session[:user_id] = 2
6869 6881

  
6870 6882
    assert_difference 'Issue.count', -3 do
test/functional/journals_controller_test.rb
62 62
  end
63 63

  
64 64
  def test_index_should_show_visible_custom_fields_only
65
    set_tmp_attachments_directory
65 66
    Issue.destroy_all
66 67
    Journal.delete_all
67 68
    field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all}
test/functional/messages_controller_test.rb
232 232
  end
233 233

  
234 234
  def test_destroy_topic
235
    set_tmp_attachments_directory
235 236
    @request.session[:user_id] = 2
236 237
    assert_difference 'Message.count', -3 do
237 238
      post :destroy, :params => {
test/functional/projects_controller_test.rb
834 834
  end
835 835

  
836 836
  def test_destroy_without_confirmation_should_show_confirmation_with_subprojects
837
    set_tmp_attachments_directory
837 838
    @request.session[:user_id] = 1 # admin
838 839

  
839 840
    assert_no_difference 'Project.count' do
......
849 850
  end
850 851

  
851 852
  def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects
853
    set_tmp_attachments_directory
852 854
    @request.session[:user_id] = 1 # admin
853 855

  
854 856
    assert_difference 'Project.count', -5 do
test/functional/wiki_controller_test.rb
273 273
  end
274 274

  
275 275
  def test_create_page_with_attachments
276
    set_tmp_attachments_directory
276 277
    @request.session[:user_id] = 2
277 278
    assert_difference 'WikiPage.count' do
278 279
      assert_difference 'Attachment.count' do
......
443 444
  end
444 445

  
445 446
  def test_update_page_with_attachments_only_should_not_create_content_version
447
    set_tmp_attachments_directory
446 448
    @request.session[:user_id] = 2
447 449
    assert_no_difference 'WikiPage.count' do
448 450
      assert_no_difference 'WikiContent.count' do
......
1179 1181
  end
1180 1182

  
1181 1183
  def test_add_attachment
1184
    set_tmp_attachments_directory
1182 1185
    @request.session[:user_id] = 2
1183 1186
    assert_difference 'Attachment.count' do
1184 1187
      post :add_attachment, :params => {
test/functional/wikis_controller_test.rb
27 27
  end
28 28

  
29 29
  def test_get_destroy_should_ask_confirmation
30
    set_tmp_attachments_directory
30 31
    @request.session[:user_id] = 1
31 32
    assert_no_difference 'Wiki.count' do
32 33
      get :destroy, :params => {:id => 1}
......
35 36
  end
36 37

  
37 38
  def test_post_destroy_should_delete_wiki
39
    set_tmp_attachments_directory
38 40
    @request.session[:user_id] = 1
39 41
    post :destroy, :params => {:id => 1, :confirm => 1}
40 42
    assert_redirected_to :controller => 'projects',
test/helpers/application_helper_test.rb
190 190
  end
191 191

  
192 192
  def test_attached_images_filename_extension
193
    set_tmp_attachments_directory
194 193
    a1 = Attachment.new(
195 194
            :container => Issue.find(1),
196 195
            :file => mock_file_with_options({:original_filename => "testtest.JPG"}),
......
264 263
    }
265 264
    attachments = [a1, a2]
266 265
    to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) }
266
  ensure
267 267
    set_tmp_attachments_directory
268 268
  end
269 269

  
......
722 722
  end
723 723

  
724 724
  def test_attachment_link_should_link_to_latest_attachment
725
    set_tmp_attachments_directory
726 725
    a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago)
727 726
    a2 = Attachment.generate!(:filename => "test.txt")
728 727
    result = link_to("test.txt", "/attachments/#{a2.id}",
test/helpers/journals_helper_test.rb
32 32
           :versions
33 33

  
34 34
  def test_journal_thumbnail_attachments_should_return_thumbnailable_attachments
35
    set_tmp_attachments_directory
35 36
    issue = Issue.generate!
36 37

  
37 38
    journal = new_record(Journal) do
test/integration/attachments_test.rb
152 152
    get "/attachments/download/4"
153 153
    assert_response :success
154 154
    assert_not_nil response.headers["X-Sendfile"]
155

  
156 155
  ensure
157 156
    set_tmp_attachments_directory
158 157
  end
test/system/issues_test.rb
149 149
    end
150 150
    assert_equal 1, issue.attachments.count
151 151
    assert_equal 'Some description', issue.attachments.first.description
152
  ensure
153
    set_fixtures_attachments_directory
154 152
  end
155 153

  
156 154
  def test_create_issue_with_new_target_version
test/unit/attachment_test.rb
344 344
    assert attachment.readable?
345 345
    attachment.update_digest_to_sha256!
346 346
    assert_equal 'ac5c6e99a21ae74b2e3f5b8e5b568be1b9107cd7153d139e822b9fe5caf50938', attachment.digest
347
  ensure
348
    set_tmp_attachments_directory
347 349
  end
348 350

  
349 351
  def test_update_attachments
......
403 405
    assert_equal 17, la1.id
404 406
    la2 = Attachment.latest_attach([a1, a2], "Testfile.PNG")
405 407
    assert_equal 17, la2.id
406

  
408
  ensure
407 409
    set_tmp_attachments_directory
408 410
  end
409 411

  
......
444 446
          assert File.exist?(thumbnail)
445 447
        end
446 448
      end
449
    ensure
450
      set_tmp_attachments_directory
447 451
    end
448 452

  
449 453
    def test_should_reuse_thumbnail
......
490 494
      set_fixtures_attachments_directory
491 495
      attachment = Attachment.find(16)
492 496
      assert_nil attachment.thumbnail
497
    ensure
498
      set_tmp_attachments_directory
493 499
    end
494 500

  
495 501
    def test_thumbnail_should_be_at_least_of_requested_size
......
508 514
        assert_equal "8e0294de2441577c529f170b6fb8f638_2654_#{generated_size}.thumb",
509 515
          File.basename(thumbnail)
510 516
      end
517
    ensure
518
      set_tmp_attachments_directory
511 519
    end
512 520
  else
513 521
    puts '(ImageMagick convert not available)'
test/unit/board_test.rb
93 93
  end
94 94

  
95 95
  def test_destroy
96
    set_tmp_attachments_directory
96 97
    board = Board.find(1)
97 98
    assert_difference 'Message.count', -6 do
98 99
      assert_difference 'Attachment.count', -1 do
test/unit/lib/redmine/export/pdf_test.rb
69 69
  end
70 70

  
71 71
  def test_attach
72
    set_fixtures_attachments_directory
72 73
    ["CP932", "SJIS"].each do |encoding|
73
      set_fixtures_attachments_directory
74

  
75 74
      str2 = "\x83e\x83X\x83g".b
76 75

  
77 76
      a1 = Attachment.find(17)
......
99 98
      assert_nil aa1
100 99
      aa2 = Redmine::Export::PDF::RDMPdfEncoding::attach(Attachment.all, "test#{str2}.png", encoding)
101 100
      assert_nil aa2
102

  
103
      set_tmp_attachments_directory
104 101
    end
102
  ensure
103
    set_tmp_attachments_directory
105 104
  end
106 105
end
test/unit/mail_handler_test.rb
542 542
  end
543 543

  
544 544
  def test_add_issue_from_apple_mail
545
    set_tmp_attachments_directory
545 546
    issue = submit_email(
546 547
              'apple_mail_with_attachment.eml',
547 548
              :issue => {:project => 'ecookbook'}
......
558 559
  end
559 560

  
560 561
  def test_thunderbird_with_attachment_ja
562
    set_tmp_attachments_directory
561 563
    issue = submit_email(
562 564
              'thunderbird_with_attachment_ja.eml',
563 565
              :issue => {:project => 'ecookbook'}
......
582 584
  end
583 585

  
584 586
  def test_gmail_with_attachment_ja
587
    set_tmp_attachments_directory
585 588
    issue = submit_email(
586 589
              'gmail_with_attachment_ja.eml',
587 590
              :issue => {:project => 'ecookbook'}
......
597 600
  end
598 601

  
599 602
  def test_thunderbird_with_attachment_latin1
603
    set_tmp_attachments_directory
600 604
    issue = submit_email(
601 605
              'thunderbird_with_attachment_iso-8859-1.eml',
602 606
              :issue => {:project => 'ecookbook'}
......
615 619
  end
616 620

  
617 621
  def test_gmail_with_attachment_latin1
622
    set_tmp_attachments_directory
618 623
    issue = submit_email(
619 624
              'gmail_with_attachment_iso-8859-1.eml',
620 625
              :issue => {:project => 'ecookbook'}
......
633 638
  end
634 639

  
635 640
  def test_mail_with_attachment_latin2
641
    set_tmp_attachments_directory
636 642
    issue = submit_email(
637 643
              'ticket_with_text_attachment_iso-8859-2.eml',
638 644
              :issue => {:project => 'ecookbook'}
......
986 992
  end
987 993

  
988 994
  def test_reply_to_a_nonexistent_issue
995
    set_tmp_attachments_directory
989 996
    Issue.find(2).destroy
990 997
    assert_no_difference 'Issue.count' do
991 998
      assert_no_difference 'Journal.count' do
test/unit/message_test.rb
108 108
  end
109 109

  
110 110
  def test_destroy_topic
111
    set_tmp_attachments_directory
111 112
    message = Message.find(1)
112 113
    board = message.board
113 114
    topics_count, messages_count = board.topics_count, board.messages_count
test/unit/project_copy_test.rb
55 55
  end
56 56

  
57 57
  test "#copy should copy project attachments" do
58
    set_tmp_attachments_directory
58 59
    Attachment.create!(:container => @source_project, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
59 60
    assert @project.copy(@source_project)
60 61

  
......
207 208
  end
208 209

  
209 210
  test "#copy should copy issue attachments" do
211
    set_tmp_attachments_directory
210 212
    issue = Issue.generate!(:subject => "copy with attachment", :tracker_id => 1, :project_id => @source_project.id)
211 213
    Attachment.create!(:container => issue, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
212 214
    @source_project.issues << issue
......
296 298
  end
297 299

  
298 300
  test "#copy should copy version attachments" do
301
    set_tmp_attachments_directory
299 302
    version = Version.generate!(:name => "copy with attachment")
300 303
    Attachment.create!(:container => version, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
301 304
    @source_project.versions << version
......
378 381
  end
379 382

  
380 383
  test "#copy should copy document attachments" do
384
    set_tmp_attachments_directory
381 385
    document = Document.generate!(:title => "copy with attachment", :category_id => 1, :project_id => @source_project.id)
382 386
    Attachment.create!(:container => document, :file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 1)
383 387
    @source_project.documents << document
test/unit/user_test.rb
262 262
  end
263 263

  
264 264
  def test_destroy_should_update_attachments
265
    set_tmp_attachments_directory
265 266
    attachment = Attachment.create!(:container => Project.find(1),
266 267
      :file => uploaded_test_file("testfile.txt", "text/plain"),
267 268
      :author_id => 2)
test/unit/wiki_page_test.rb
143 143
  end
144 144

  
145 145
  def test_destroy_should_delete_content_and_its_versions
146
    set_tmp_attachments_directory
146 147
    page = WikiPage.find(1)
147 148
    assert_difference 'WikiPage.count', -1 do
148 149
      assert_difference 'WikiContent.count', -1 do
test/unit/wiki_test.rb
103 103
  end
104 104

  
105 105
  def test_destroy_should_remove_redirects_from_the_wiki
106
    set_tmp_attachments_directory
106 107
    WikiRedirect.create!(:wiki_id => 1, :title => 'Foo', :redirects_to_wiki_id => 2, :redirects_to => 'Bar')
107 108

  
108 109
    Wiki.find(1).destroy
......
110 111
  end
111 112

  
112 113
  def test_destroy_should_remove_redirects_to_the_wiki
114
    set_tmp_attachments_directory
113 115
    WikiRedirect.create!(:wiki_id => 2, :title => 'Foo', :redirects_to_wiki_id => 1, :redirects_to => 'Bar')
114 116

  
115 117
    Wiki.find(1).destroy
    (1-1/1)