]> source.dussan.org Git - redmine.git/commitdiff
Updating custom fields does not trigger update to "updated_on" field in the customize...
authorGo MAEDA <maeda@farend.jp>
Sat, 29 Feb 2020 06:42:00 +0000 (06:42 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 29 Feb 2020 06:42:00 +0000 (06:42 +0000)
Patch by Yuichi HARADA.

git-svn-id: http://svn.redmine.org/redmine/trunk@19541 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
test/functional/projects_controller_test.rb

index 96fdbf8b6f38137e4dc31c4aa45f6de4550b4699..73b2ae84794410a18a6224b763f09b3195539877 100644 (file)
@@ -146,6 +146,7 @@ module Redmine
           end
           self.custom_values = target_custom_values
           custom_values.each(&:save)
+          touch if !saved_changes? && custom_values.any?(&:saved_changes?)
           @custom_field_values_changed = false
           true
         end
index 6be670566114c02804da62955e4c8b2f16d1d9e8..a49e609ce92a150585dc6fe340152fefe7736c71 100644 (file)
@@ -994,6 +994,30 @@ class ProjectsControllerTest < Redmine::ControllerTest
     assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort
   end
 
+  def test_update_custom_field_should_update_updated_on
+    @request.session[:user_id] = 2
+    project = Project.find(1)
+    project.update_attribute :updated_on, nil
+    assert_equal 'Stable', project.custom_value_for(3).value
+
+    travel_to Time.current do
+      post(
+        :update,
+        :params => {
+          :id => 1,
+          :project => {
+            :custom_field_values => {'3' => 'Alpha'}
+          }
+        }
+      )
+      assert_redirected_to '/projects/ecookbook/settings'
+      assert_equal 'Successful update.', flash[:notice]
+      project.reload
+      assert_equal 'Alpha', project.custom_value_for(3).value
+      assert_equal Time.current, project.updated_on
+    end
+  end
+
   def test_destroy_leaf_project_without_confirmation_should_show_confirmation
     @request.session[:user_id] = 1 # admin