@@ -302,16 +302,19 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 tracker != tracker_was | |||
306 | if status == default_status |
|
307 | if status == default_status | |
307 | self.status = nil |
|
308 | self.status = nil | |
308 | elsif status && tracker && !tracker.issue_status_ids.include?(status.id) |
|
309 | elsif status && tracker && !tracker.issue_status_ids.include?(status.id) | |
309 | self.status = nil |
|
310 | self.status = nil | |
310 | end |
|
311 | end | |
311 | @custom_field_values = nil |
|
|||
312 | @workflow_rule_by_attribute = nil |
|
312 | @workflow_rule_by_attribute = nil | |
313 | end |
|
313 | end | |
314 | association(:tracker).writer(tracker) |
|
314 | association(:tracker).writer(tracker) | |
|
315 | if tracker != tracker_was | |||
|
316 | reassign_custom_field_values | |||
|
317 | end | |||
315 | self.status ||= default_status |
|
318 | self.status ||= default_status | |
316 | self.tracker |
|
319 | self.tracker | |
317 | end |
|
320 | end | |
@@ -355,7 +358,7 class Issue < ActiveRecord::Base | |||||
355 | unless valid_parent_project? |
|
358 | unless valid_parent_project? | |
356 | self.parent_issue_id = nil |
|
359 | self.parent_issue_id = nil | |
357 | end |
|
360 | end | |
358 |
|
|
361 | reassign_custom_field_values | |
359 | @workflow_rule_by_attribute = nil |
|
362 | @workflow_rule_by_attribute = nil | |
360 | end |
|
363 | end | |
361 | # Set fixed_version to the project default version if it's valid |
|
364 | # 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 |
@@ -3001,6 +3001,24 class IssuesControllerTest < ActionController::TestCase | |||||
3001 | assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort |
|
3001 | assert_equal issue.descendants.map(&:subject).sort, copy.descendants.map(&:subject).sort | |
3002 | end |
|
3002 | end | |
3003 |
|
3003 | |||
|
3004 | def test_create_as_copy_to_a_different_project_should_copy_subtask_custom_fields | |||
|
3005 | issue = Issue.generate! {|i| i.custom_field_values = {'2' => 'Foo'}} | |||
|
3006 | child = Issue.generate!(:parent_issue_id => issue.id) {|i| i.custom_field_values = {'2' => 'Bar'}} | |||
|
3007 | @request.session[:user_id] = 1 | |||
|
3008 | ||||
|
3009 | assert_difference 'Issue.count', 2 do | |||
|
3010 | post :create, :project_id => 'ecookbook', :copy_from => issue.id, | |||
|
3011 | :issue => {:project_id => '2', :tracker_id => 1, :status_id => '1', | |||
|
3012 | :subject => 'Copy with subtasks', :custom_field_values => {'2' => 'Foo'}}, | |||
|
3013 | :copy_subtasks => '1' | |||
|
3014 | end | |||
|
3015 | ||||
|
3016 | child_copy, issue_copy = Issue.order(:id => :desc).limit(2).to_a | |||
|
3017 | assert_equal 2, issue_copy.project_id | |||
|
3018 | assert_equal 'Foo', issue_copy.custom_field_value(2) | |||
|
3019 | assert_equal 'Bar', child_copy.custom_field_value(2) | |||
|
3020 | end | |||
|
3021 | ||||
3004 | def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks |
|
3022 | def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks | |
3005 | @request.session[:user_id] = 2 |
|
3023 | @request.session[:user_id] = 2 | |
3006 | issue = Issue.generate_with_descendants! |
|
3024 | issue = Issue.generate_with_descendants! |
General Comments 0
You need to be logged in to leave comments.
Login now