@@ -848,6 +848,9 class Project < ActiveRecord::Base | |||
|
848 | 848 | new_issue = Issue.new |
|
849 | 849 | new_issue.copy_from(issue, :subtasks => false, :link => false) |
|
850 | 850 | new_issue.project = self |
|
851 | # Changing project resets the custom field values | |
|
852 | # TODO: handle this in Issue#project= | |
|
853 | new_issue.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h} | |
|
851 | 854 | # Reassign fixed_versions by name, since names are unique per project |
|
852 | 855 | if issue.fixed_version && issue.fixed_version.project == project |
|
853 | 856 | new_issue.fixed_version = self.versions.detect {|v| v.name == issue.fixed_version.name} |
@@ -69,6 +69,19 class ProjectCopyTest < ActiveSupport::TestCase | |||
|
69 | 69 | assert_equal "Closed", copied_issue.status.name |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | test "#copy should copy issues custom values" do | |
|
73 | field = IssueCustomField.generate!(:is_for_all => true, :trackers => Tracker.all) | |
|
74 | issue = Issue.generate!(:project => @source_project, :subject => 'Custom field copy') | |
|
75 | issue.custom_field_values = {field.id => 'custom'} | |
|
76 | issue.save! | |
|
77 | assert_equal 'custom', issue.reload.custom_field_value(field) | |
|
78 | ||
|
79 | assert @project.copy(@source_project) | |
|
80 | copy = @project.issues.find_by_subject('Custom field copy') | |
|
81 | assert copy | |
|
82 | assert_equal 'custom', copy.reload.custom_field_value(field) | |
|
83 | end | |
|
84 | ||
|
72 | 85 | test "#copy should copy issues assigned to a locked version" do |
|
73 | 86 | User.current = User.find(1) |
|
74 | 87 | assigned_version = Version.generate!(:name => "Assigned Issues") |
General Comments 0
You need to be logged in to leave comments.
Login now