mirror of
https://github.com/redmine/redmine.git
synced 2025-11-09 14:56:01 +01:00
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:
@@ -235,6 +235,13 @@ class IssuesController < ApplicationController
|
|||||||
|
|
||||||
unsaved_issue_ids = []
|
unsaved_issue_ids = []
|
||||||
moved_issues = []
|
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|
|
@issues.each do |issue|
|
||||||
issue.reload
|
issue.reload
|
||||||
if @copy
|
if @copy
|
||||||
|
|||||||
@@ -3539,6 +3539,21 @@ class IssuesControllerTest < ActionController::TestCase
|
|||||||
assert_equal count, copy.descendants.count
|
assert_equal count, copy.descendants.count
|
||||||
end
|
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
|
def test_bulk_copy_to_another_project_should_follow_when_needed
|
||||||
@request.session[:user_id] = 2
|
@request.session[:user_id] = 2
|
||||||
post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1'
|
post :bulk_update, :ids => [1], :copy => '1', :issue => {:project_id => 2}, :follow => '1'
|
||||||
|
|||||||
Reference in New Issue
Block a user