0001-fix-issue_copy-do_not_journalize_attachments.patch

Jens Krämer, 2021-03-18 09:47

Download (1.78 KB)

View differences:

app/models/issue.rb
1887 1887

  
1888 1888
  # Callback on file attachment
1889 1889
  def attachment_added(attachment)
1890
    if current_journal && !attachment.new_record?
1890
    if current_journal && !attachment.new_record? && !copy?
1891 1891
      current_journal.journalize_attachment(attachment, :added)
1892 1892
    end
1893 1893
  end
test/unit/issue_test.rb
1511 1511
    assert_equal [3, nil], copy.children.map(&:assigned_to_id)
1512 1512
  end
1513 1513

  
1514
  def test_copy_should_not_add_attachments_to_journal
1515
    set_tmp_attachments_directory
1516
    issue = Issue.generate!
1517
    copy = Issue.new
1518
    copy.init_journal User.find(1)
1519
    copy.copy_from issue
1520

  
1521
    copy.project = issue.project
1522
    copy.save_attachments(
1523
      { 'p0' => {'file' => mock_file_with_options(:original_filename => 'upload')} }
1524
    )
1525
    assert copy.save
1526
    assert j = copy.journals.last
1527
    assert_equal 1, j.details.size
1528
    assert_equal 'relation', j.details[0].property
1529
  end
1530

  
1514 1531
  def test_should_not_call_after_project_change_on_creation
1515 1532
    issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
1516 1533
                      :subject => 'Test', :author_id => 1)
1517
-