mirror of
https://github.com/redmine/redmine.git
synced 2025-11-08 14:26:04 +01:00
Clear subtask assignee during copy if is locked (#28946).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@17390 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -1642,6 +1642,7 @@ class Issue < ActiveRecord::Base
|
|||||||
copy.project = project
|
copy.project = project
|
||||||
copy.parent_issue_id = copied_issue_ids[child.parent_id]
|
copy.parent_issue_id = copied_issue_ids[child.parent_id]
|
||||||
copy.fixed_version_id = nil unless child.fixed_version.present? && child.fixed_version.status == 'open'
|
copy.fixed_version_id = nil unless child.fixed_version.present? && child.fixed_version.status == 'open'
|
||||||
|
copy.assigned_to = nil unless child.assigned_to_id.present? && child.assigned_to.status == User::STATUS_ACTIVE
|
||||||
unless copy.save
|
unless copy.save
|
||||||
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
|
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
|
||||||
next
|
next
|
||||||
|
|||||||
@@ -1413,6 +1413,25 @@ class IssueTest < ActiveSupport::TestCase
|
|||||||
assert_equal [3, nil], copy.children.map(&:fixed_version_id)
|
assert_equal [3, nil], copy.children.map(&:fixed_version_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_copy_should_clear_subtasks_assignee_if_is_locked
|
||||||
|
user = User.find(2)
|
||||||
|
|
||||||
|
parent = Issue.generate!
|
||||||
|
child1 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 1', :assigned_to_id => 3)
|
||||||
|
child2 = Issue.generate!(:parent_issue_id => parent.id, :subject => 'Child 2', :assigned_to_id => user.id)
|
||||||
|
|
||||||
|
user.status = User::STATUS_LOCKED
|
||||||
|
user.save!
|
||||||
|
|
||||||
|
copy = parent.reload.copy
|
||||||
|
|
||||||
|
assert_difference 'Issue.count', 3 do
|
||||||
|
assert copy.save
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal [3, nil], copy.children.map(&:assigned_to_id)
|
||||||
|
end
|
||||||
|
|
||||||
def test_should_not_call_after_project_change_on_creation
|
def test_should_not_call_after_project_change_on_creation
|
||||||
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
|
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
|
||||||
:subject => 'Test', :author_id => 1)
|
:subject => 'Test', :author_id => 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user