Adapt subtasks copy when copying a project (#6965).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10328 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-09-08 05:56:48 +00:00
parent 5003927f13
commit 6a37151b5c
2 changed files with 17 additions and 1 deletions

View File

@ -773,7 +773,7 @@ class Project < ActiveRecord::Base
# get copied before their children
project.issues.find(:all, :order => 'root_id, lft').each do |issue|
new_issue = Issue.new
new_issue.copy_from(issue)
new_issue.copy_from(issue, :subtasks => false)
new_issue.project = self
# Reassign fixed_versions by name, since names are unique per
# project and the versions for self are not yet saved

View File

@ -1018,7 +1018,23 @@ class ProjectTest < ActiveSupport::TestCase
assert @project.issue_categories.any?
assert @project.issues.empty?
end
end
def test_copy_should_copy_subtasks
source = Project.generate!(:tracker_ids => [1])
issue = Issue.generate_with_descendants!(source, :subject => 'Parent')
project = Project.new(:name => 'Copy', :identifier => 'copy', :tracker_ids => [1])
assert_difference 'Project.count' do
assert_difference 'Issue.count', 1+issue.descendants.count do
assert project.copy(source.reload)
end
end
copy = Issue.where(:parent_id => nil).order("id DESC").first
assert_equal project, copy.project
assert_equal issue.descendants.count, copy.descendants.count
child_copy = copy.children.detect {|c| c.subject == 'Child1'}
assert child_copy.descendants.any?
end
context "#start_date" do