]> source.dussan.org Git - redmine.git/commitdiff
Fixed that target version is lost on project copy for issues that are assigned to...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 9 Sep 2012 10:01:03 +0000 (10:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 9 Sep 2012 10:01:03 +0000 (10:01 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10333 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/project.rb
test/unit/project_test.rb

index e3889ff234b4def02c59dbf1a49a197ca76176f1..da58c96dbe519a4c8ac1d72a13dc9fa1dc108256 100644 (file)
@@ -776,7 +776,7 @@ class Project < ActiveRecord::Base
       new_issue.copy_from(issue, :subtasks => false)
       new_issue.project = self
       # Reassign fixed_versions by name, since names are unique per project
-      if issue.fixed_version
+      if issue.fixed_version && issue.fixed_version.project == project
         new_issue.fixed_version = self.versions.detect {|v| v.name == issue.fixed_version.name}
       end
       # Reassign the category by name, since names are unique per project
index 1171c5e932e3fb7a7d0e22d2f4e0e4bd9a90afde..fac2307edd2a1e7f9b72eb5655c0fed673c7dbb1 100644 (file)
@@ -844,6 +844,22 @@ class ProjectTest < ActiveSupport::TestCase
       assert_not_equal assigned_version.id, copied_issue.fixed_version.id # Different record
     end
 
+    should "keep target shared versions from other project" do
+      assigned_version = Version.generate!(:name => "Assigned Issues", :status => 'open', :project_id => 1, :sharing => 'system')
+      issue = Issue.generate_for_project!(@source_project,
+                                  :fixed_version => assigned_version,
+                                  :subject => "keep target shared versions",
+                                  :tracker_id => 1,
+                                  :project_id => @source_project.id)
+
+      assert @project.copy(@source_project)
+      @project.reload
+      copied_issue = @project.issues.first(:conditions => {:subject => "keep target shared versions"})
+
+      assert copied_issue
+      assert_equal assigned_version, copied_issue.fixed_version
+    end
+
     should "copy issue relations" do
       Setting.cross_project_issue_relations = '1'