@@ -278,6 +278,22 class IssueTest < ActiveSupport::TestCase | |||
|
278 | 278 | assert_equal custom_value.id, issue.custom_value_for(field).id |
|
279 | 279 | end |
|
280 | 280 | |
|
281 | def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields | |
|
282 | issue = Issue.new(:project_id => 1) | |
|
283 | issue.attributes = {:tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'Test', :custom_field_values => {'2' => 'Test'}} | |
|
284 | issue.save! | |
|
285 | ||
|
286 | assert !Tracker.find(2).custom_field_ids.include?(2) | |
|
287 | ||
|
288 | issue = Issue.find(issue.id) | |
|
289 | issue.attributes = {:tracker_id => 2, :custom_field_values => {'1' => ''}} | |
|
290 | ||
|
291 | issue = Issue.find(issue.id) | |
|
292 | custom_value = issue.custom_value_for(2) | |
|
293 | assert_not_nil custom_value | |
|
294 | assert_equal 'Test', custom_value.value | |
|
295 | end | |
|
296 | ||
|
281 | 297 | def test_assigning_tracker_id_should_reload_custom_fields_values |
|
282 | 298 | issue = Issue.new(:project => Project.find(1)) |
|
283 | 299 | assert issue.custom_field_values.empty? |
@@ -71,7 +71,6 module Redmine | |||
|
71 | 71 | custom_field_values.each do |custom_value| |
|
72 | 72 | custom_value.value = values[custom_value.custom_field_id.to_s] if values.has_key?(custom_value.custom_field_id.to_s) |
|
73 | 73 | end if values.is_a?(Hash) |
|
74 | self.custom_values = custom_field_values | |
|
75 | 74 | end |
|
76 | 75 | |
|
77 | 76 | def custom_field_values |
@@ -92,6 +91,7 module Redmine | |||
|
92 | 91 | end |
|
93 | 92 | |
|
94 | 93 | def save_custom_field_values |
|
94 | self.custom_values = custom_field_values | |
|
95 | 95 | custom_field_values.each(&:save) |
|
96 | 96 | @custom_field_values_changed = false |
|
97 | 97 | @custom_field_values = nil |
General Comments 0
You need to be logged in to leave comments.
Login now