Defect #28946 » 0001-clear-subtask-assignee-during-copy-if-is-locked.patch
app/models/issue.rb | ||
---|---|---|
1642 | 1642 |
copy.project = project |
1643 | 1643 |
copy.parent_issue_id = copied_issue_ids[child.parent_id] |
1644 | 1644 |
copy.fixed_version_id = nil unless child.fixed_version.present? && child.fixed_version.status == 'open' |
1645 |
copy.assigned_to = nil unless child.assigned_to_id.present? && child.assigned_to.status == User::STATUS_ACTIVE |
|
1645 | 1646 |
unless copy.save |
1646 | 1647 |
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 |
1647 | 1648 |
next |
test/unit/issue_test.rb | ||
---|---|---|
1413 | 1413 |
assert_equal [3, nil], copy.children.map(&:fixed_version_id) |
1414 | 1414 |
end |
1415 | 1415 | |
1416 |
def test_copy_should_clear_subtasks_assignee_if_is_locked |
|
1417 |
user = User.find(2) |
|
1418 | ||
1419 |
parent = Issue.generate! |
|
1420 |
child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1', :assigned_to_id => 3) |
|
1421 |
child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2', :assigned_to_id => user.id) |
|
1422 | ||
1423 |
user.status = User::STATUS_LOCKED |
|
1424 |
user.save! |
|
1425 | ||
1426 |
copy = parent.reload.copy |
|
1427 | ||
1428 |
assert_difference 'Issue.count', 3 do |
|
1429 |
assert copy.save |
|
1430 |
end |
|
1431 | ||
1432 |
assert_equal [3, nil], copy.children.map(&:assigned_to_id) |
|
1433 |
end |
|
1434 | ||
1416 | 1435 |
def test_should_not_call_after_project_change_on_creation |
1417 | 1436 |
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1, |
1418 | 1437 |
:subject => 'Test', :author_id => 1) |