@@ -302,16 +302,17 class Issue < ActiveRecord::Base | |||||
302 | # * or if the status was not part of the new tracker statuses |
|
302 | # * or if the status was not part of the new tracker statuses | |
303 | # * or the status was nil |
|
303 | # * or the status was nil | |
304 | def tracker=(tracker) |
|
304 | def tracker=(tracker) | |
305 |
|
|
305 | tracker_was = self.tracker | |
306 | if status == default_status |
|
306 | association(:tracker).writer(tracker) | |
|
307 | if tracker != tracker_was | |||
|
308 | if status == tracker_was.try(:default_status) | |||
307 | self.status = nil |
|
309 | self.status = nil | |
308 | elsif status && tracker && !tracker.issue_status_ids.include?(status.id) |
|
310 | elsif status && tracker && !tracker.issue_status_ids.include?(status.id) | |
309 | self.status = nil |
|
311 | self.status = nil | |
310 | end |
|
312 | end | |
311 |
|
|
313 | reassign_custom_field_values | |
312 | @workflow_rule_by_attribute = nil |
|
314 | @workflow_rule_by_attribute = nil | |
313 | end |
|
315 | end | |
314 | association(:tracker).writer(tracker) |
|
|||
315 | self.status ||= default_status |
|
316 | self.status ||= default_status | |
316 | self.tracker |
|
317 | self.tracker | |
317 | end |
|
318 | end | |
@@ -355,7 +356,7 class Issue < ActiveRecord::Base | |||||
355 | unless valid_parent_project? |
|
356 | unless valid_parent_project? | |
356 | self.parent_issue_id = nil |
|
357 | self.parent_issue_id = nil | |
357 | end |
|
358 | end | |
358 |
|
|
359 | reassign_custom_field_values | |
359 | @workflow_rule_by_attribute = nil |
|
360 | @workflow_rule_by_attribute = nil | |
360 | end |
|
361 | end | |
361 | # Set fixed_version to the project default version if it's valid |
|
362 | # Set fixed_version to the project default version if it's valid |
@@ -151,6 +151,14 module Redmine | |||||
151 | true |
|
151 | true | |
152 | end |
|
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 | def reset_custom_values! |
|
162 | def reset_custom_values! | |
155 | @custom_field_values = nil |
|
163 | @custom_field_values = nil | |
156 | @custom_field_values_changed = true |
|
164 | @custom_field_values_changed = true |
@@ -2982,6 +2982,24 class IssuesControllerTest < ActionController::TestCase | |||||
2982 | assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort |
|
2982 | assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort | |
2983 | end |
|
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 | def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks |
|
3003 | def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks | |
2986 | @request.session[:user_id] = 2 |
|
3004 | @request.session[:user_id] = 2 | |
2987 | issue = Issue.generate_with_descendants! |
|
3005 | issue = Issue.generate_with_descendants! |
General Comments 0
You need to be logged in to leave comments.
Login now