Do not copy subtasks twice when copying an issue and its descendants (#6965).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10329 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
6a37151b5c
commit
b72d40a429
|
@ -235,6 +235,13 @@ class IssuesController < ApplicationController
|
|||
|
||||
unsaved_issue_ids = []
|
||||
moved_issues = []
|
||||
|
||||
if @copy && params[:copy_subtasks].present?
|
||||
# Descendant issues will be copied with the parent task
|
||||
# Don't copy them twice
|
||||
@issues.reject! {|issue| @issues.detect {|other| issue.is_descendant_of?(other)}}
|
||||
end
|
||||
|
||||
@issues.each do |issue|
|
||||
issue.reload
|
||||
if @copy
|
||||
|
|
|
@ -3539,6 +3539,21 @@ class IssuesControllerTest < ActionController::TestCase
|
|||
assert_equal count, copy.descendants.count
|
||||
end
|
||||
|
||||
def test_bulk_copy_should_not_copy_selected_subtasks_twice
|
||||
issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
|
||||
count = issue.descendants.count
|
||||
@request.session[:user_id] = 2
|
||||
|
||||
assert_difference 'Issue.count', count+1 do
|
||||
post :bulk_update, :ids => issue.self_and_descendants.map(&:id), :copy => '1', :copy_subtasks => '1',
|
||||
:issue => {
|
||||
:project_id => ''
|
||||
}
|
||||
end
|
||||
copy = Issue.where(:parent_id => nil).order("id DESC").first
|
||||
assert_equal count, copy.descendants.count
|
||||
end
|
||||
|
||||
def test_bulk_copy_to_another_project_should_follow_when_needed
|
||||
@request.session[:user_id] = 2
|
||||
post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1'
|
||||
|
|
Loading…
Reference in New Issue