@@ -302,16 +302,17 class Issue < ActiveRecord::Base | |||
|
302 | 302 | # * or if the status was not part of the new tracker statuses |
|
303 | 303 | # * or the status was nil |
|
304 | 304 | def tracker=(tracker) |
|
305 |
|
|
|
306 | if status == default_status | |
|
305 | tracker_was = self.tracker | |
|
306 | association(:tracker).writer(tracker) | |
|
307 | if tracker != tracker_was | |
|
308 | if status == tracker_was.try(:default_status) | |
|
307 | 309 | self.status = nil |
|
308 | 310 | elsif status && tracker && !tracker.issue_status_ids.include?(status.id) |
|
309 | 311 | self.status = nil |
|
310 | 312 | end |
|
311 |
|
|
|
313 | reassign_custom_field_values | |
|
312 | 314 | @workflow_rule_by_attribute = nil |
|
313 | 315 | end |
|
314 | association(:tracker).writer(tracker) | |
|
315 | 316 | self.status ||= default_status |
|
316 | 317 | self.tracker |
|
317 | 318 | end |
@@ -355,7 +356,7 class Issue < ActiveRecord::Base | |||
|
355 | 356 | unless valid_parent_project? |
|
356 | 357 | self.parent_issue_id = nil |
|
357 | 358 | end |
|
358 |
|
|
|
359 | reassign_custom_field_values | |
|
359 | 360 | @workflow_rule_by_attribute = nil |
|
360 | 361 | end |
|
361 | 362 | # Set fixed_version to the project default version if it's valid |
@@ -151,6 +151,14 module Redmine | |||
|
151 | 151 | true |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | def reassign_custom_field_values | |
|
155 | if @custom_field_values | |
|
156 | values = @custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h} | |
|
157 | @custom_field_values = nil | |
|
158 | self.custom_field_values = values | |
|
159 | end | |
|
160 | end | |
|
161 | ||
|
154 | 162 | def reset_custom_values! |
|
155 | 163 | @custom_field_values = nil |
|
156 | 164 | @custom_field_values_changed = true |
@@ -2982,6 +2982,24 class IssuesControllerTest < ActionController::TestCase | |||
|
2982 | 2982 | assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort |
|
2983 | 2983 | end |
|
2984 | 2984 | |
|
2985 | def test_create_as_copy_to_a_different_project_should_copy_subtask_custom_fields | |
|
2986 | issue = Issue.generate! {|i| i.custom_field_values = {'2' => 'Foo'}} | |
|
2987 | child = Issue.generate!(:parent_issue_id => issue.id) {|i| i.custom_field_values = {'2' => 'Bar'}} | |
|
2988 | @request.session[:user_id] = 1 | |
|
2989 | ||
|
2990 | assert_difference 'Issue.count', 2 do | |
|
2991 | post :create, :project_id => 'ecookbook', :copy_from => issue.id, | |
|
2992 | :issue => {:project_id => '2', :tracker_id => 1, :status_id => '1', | |
|
2993 | :subject => 'Copy with subtasks', :custom_field_values => {'2' => 'Foo'}}, | |
|
2994 | :copy_subtasks => '1' | |
|
2995 | end | |
|
2996 | ||
|
2997 | child_copy, issue_copy = Issue.order(:id => :desc).limit(2).to_a | |
|
2998 | assert_equal 2, issue_copy.project_id | |
|
2999 | assert_equal 'Foo', issue_copy.custom_field_value(2) | |
|
3000 | assert_equal 'Bar', child_copy.custom_field_value(2) | |
|
3001 | end | |
|
3002 | ||
|
2985 | 3003 | def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks |
|
2986 | 3004 | @request.session[:user_id] = 2 |
|
2987 | 3005 | issue = Issue.generate_with_descendants! |
General Comments 0
You need to be logged in to leave comments.
Login now