diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-10 11:56:13 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-10 11:56:13 +0000 |
commit | 1848fcd91e070f19b736920f456d7c4d7a91ab8f (patch) | |
tree | 1d000c8b905092c294bc1f2f0fac4ef94efc2be3 | |
parent | 40a14cafbc3f20ec0df0b82fe6a9c3bc0a13850e (diff) | |
download | redmine-1848fcd91e070f19b736920f456d7c4d7a91ab8f.tar.gz redmine-1848fcd91e070f19b736920f456d7c4d7a91ab8f.zip |
Merged r8103 from trunk (#9737).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.2-stable@8157 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | test/unit/issue_test.rb | 16 | ||||
-rw-r--r-- | vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index d19c9458c..617b121d2 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -232,6 +232,22 @@ class IssueTest < ActiveSupport::TestCase assert_equal custom_value.id, issue.custom_value_for(field).id end + def test_should_not_update_custom_fields_on_changing_tracker_with_different_custom_fields + issue = Issue.new(:project_id => 1) + issue.attributes = {:tracker_id => 1, :author_id => 1, :status_id => 1, :subject => 'Test', :custom_field_values => {'2' => 'Test'}} + issue.save! + + assert !Tracker.find(2).custom_field_ids.include?(2) + + issue = Issue.find(issue.id) + issue.attributes = {:tracker_id => 2, :custom_field_values => {'1' => ''}} + + issue = Issue.find(issue.id) + custom_value = issue.custom_value_for(2) + assert_not_nil custom_value + assert_equal 'Test', custom_value.value + end + def test_assigning_tracker_id_should_reload_custom_fields_values issue = Issue.new(:project => Project.find(1)) assert issue.custom_field_values.empty? diff --git a/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb index 10ba12341..422b3ccb9 100644 --- a/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb +++ b/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb @@ -71,7 +71,6 @@ module Redmine custom_field_values.each do |custom_value| custom_value.value = values[custom_value.custom_field_id.to_s] if values.has_key?(custom_value.custom_field_id.to_s) end if values.is_a?(Hash) - self.custom_values = custom_field_values end def custom_field_values @@ -92,6 +91,7 @@ module Redmine end def save_custom_field_values + self.custom_values = custom_field_values custom_field_values.each(&:save) @custom_field_values_changed = false @custom_field_values = nil |