0001-Clear-target-version-when-copying-an-issue-if-status.patch

Marius BALTEANU, 2018-06-04 23:24

Download (2.12 KB)

View differences:

app/models/issue.rb
1638 1638
        copy.author = author
1639 1639
        copy.project = project
1640 1640
        copy.parent_issue_id = copied_issue_ids[child.parent_id]
1641
        copy.fixed_version_id = nil unless child.fixed_version.present? && child.fixed_version.status == 'open'
1641 1642
        unless copy.save
1642 1643
          logger.error "Could not copy subtask ##{child.id} while copying ##{@copied_from.id} to ##{id} due to validation errors: #{copy.errors.full_messages.join(', ')}" if logger
1643 1644
          next
test/unit/issue_test.rb
1393 1393
    assert !issue.watched_by?(user2)
1394 1394
  end
1395 1395

  
1396
  def test_copy_should_clear_subtasks_target_version_if_locked_or_closed
1397
    version = Version.new(:project => Project.find(1), :name => '2.1',)
1398
    version.save!
1399

  
1400
    parent = Issue.generate!
1401
    child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1', :fixed_version_id => 3)
1402
    child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2', :fixed_version_id => version.id)
1403

  
1404
    version.status = 'locked'
1405
    version.save!
1406

  
1407
    copy = parent.reload.copy
1408

  
1409
    assert_difference 'Issue.count', 3 do
1410
      assert copy.save
1411
    end
1412

  
1413
    assert_equal [3, nil], copy.children.map(&:fixed_version_id)
1414
  end
1415

  
1396 1416
  def test_should_not_call_after_project_change_on_creation
1397 1417
    issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
1398 1418
                      :subject => 'Test', :author_id => 1)
1399
-