summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-02-11 04:06:25 +0000
committerGo MAEDA <maeda@farend.jp>2020-02-11 04:06:25 +0000
commit89c4e1680766e1e5a3a11a857f17852cab3c2437 (patch)
treeabda2dcc8e080c0b46fb8818b679a3a26836ceab
parentad0ea14d681c50ff08ac6bc82ddf0ae465e9e832 (diff)
downloadredmine-89c4e1680766e1e5a3a11a857f17852cab3c2437.tar.gz
redmine-89c4e1680766e1e5a3a11a857f17852cab3c2437.zip
Updating custom fields does not trigger update to "updated_on" field in the customized object (#5354).
Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@19510 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb2
-rw-r--r--test/functional/projects_controller_test.rb24
2 files changed, 26 insertions, 0 deletions
diff --git a/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
index 96fdbf8b6..3703a5e65 100644
--- a/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
+++ b/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
@@ -145,7 +145,9 @@ module Redmine
end
end
self.custom_values = target_custom_values
+ custom_values_changed = custom_values.any?(&:changed?)
custom_values.each(&:save)
+ touch if persisted? && custom_values_changed
@custom_field_values_changed = false
true
end
diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb
index 6be670566..a49e609ce 100644
--- a/test/functional/projects_controller_test.rb
+++ b/test/functional/projects_controller_test.rb
@@ -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