@@ -232,6 +232,22 class IssueTest < ActiveSupport::TestCase | |||
|
232 | 232 | assert_equal custom_value.id, issue.custom_value_for(field).id |
|
233 | 233 | end |
|
234 | 234 | |
|
235 | def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields | |
|
236 | issue = Issue.new(:project_id => 1) | |
|
237 | issue.attributes = {:tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'Test', :custom_field_values => {'2' => 'Test'}} | |
|
238 | issue.save! | |
|
239 | ||
|
240 | assert !Tracker.find(2).custom_field_ids.include?(2) | |
|
241 | ||
|
242 | issue = Issue.find(issue.id) | |
|
243 | issue.attributes = {:tracker_id => 2, :custom_field_values => {'1' => ''}} | |
|
244 | ||
|
245 | issue = Issue.find(issue.id) | |
|
246 | custom_value = issue.custom_value_for(2) | |
|
247 | assert_not_nil custom_value | |
|
248 | assert_equal 'Test', custom_value.value | |
|
249 | end | |
|
250 | ||
|
235 | 251 | def test_assigning_tracker_id_should_reload_custom_fields_values |
|
236 | 252 | issue = Issue.new(:project => Project.find(1)) |
|
237 | 253 | 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