]> source.dussan.org Git - redmine.git/commitdiff
Fixed that custom_field_values are not reloaded on #reload (#13119).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 11 Feb 2013 17:38:30 +0000 (17:38 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 11 Feb 2013 17:38:30 +0000 (17:38 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11349 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
test/unit/issue_test.rb

index e896d921cbccc3c5b8ca8864b43453e16527c400..28cefd4ef4570a7baf44465596628c67a2b7f55d 100644 (file)
@@ -32,6 +32,8 @@ module Redmine
                                    :order => "#{CustomField.table_name}.position",
                                    :dependent => :delete_all,
                                    :validate => false
+
+          send :alias_method, :reload_without_custom_fields, :reload
           send :include, Redmine::Acts::Customizable::InstanceMethods
           validate :validate_custom_field_values
           after_save :save_custom_field_values
@@ -152,6 +154,12 @@ module Redmine
           @custom_field_values_changed = true
         end
 
+        def reload(*args)
+          @custom_field_values = nil
+          @custom_field_values_changed = false
+          reload_without_custom_fields(*args)
+        end
+
         module ClassMethods
         end
       end
index ad283e64acb5140a7efc74b7a809203de2134ce7..1ffc24dd528db3fa273dd29772303e2060c64d69 100644 (file)
@@ -421,6 +421,21 @@ class IssueTest < ActiveSupport::TestCase
     assert_equal 'MySQL', issue.custom_field_value(1)
   end
 
+  def test_reload_should_reload_custom_field_values
+    issue = Issue.generate!
+    issue.custom_field_values = {'2' => 'Foo'}
+    issue.save!
+
+    issue = Issue.order('id desc').first
+    assert_equal 'Foo', issue.custom_field_value(2)
+
+    issue.custom_field_values = {'2' => 'Bar'}
+    assert_equal 'Bar', issue.custom_field_value(2)
+
+    issue.reload
+    assert_equal 'Foo', issue.custom_field_value(2)
+  end
+
   def test_should_update_issue_with_disabled_tracker
     p = Project.find(1)
     issue = Issue.find(1)