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 5dcc97dc60..80e001995b 100644 --- a/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb +++ b/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb @@ -47,7 +47,7 @@ module Redmine dependent: :delete_all, validate: false before_validation { |customized| customized.custom_field_values if customized.new_record? } - validate :validate_custom_values, if: -> (customized) { customized.custom_field_values_changed? } + validate :validate_custom_values send :include, Redmine::Acts::Customizable::InstanceMethods # Save custom values when saving the customized object after_save :save_custom_field_values diff --git a/test/unit/time_entry_activity_test.rb b/test/unit/time_entry_activity_test.rb index 1d56cdf7e7..07350b4711 100644 --- a/test/unit/time_entry_activity_test.rb +++ b/test/unit/time_entry_activity_test.rb @@ -62,7 +62,8 @@ class TimeEntryActivityTest < ActiveSupport::TestCase e = TimeEntryActivity.new(name: 'Custom Data') assert !e.save - assert_include e.errors[:custom_values], I18n.translate('activerecord.errors.messages.invalid') + assert_include e.errors["custom_field_#{field.id}"], + I18n.translate('activerecord.errors.messages.blank') end def test_create_with_required_custom_field_should_succeed @@ -85,7 +86,7 @@ class TimeEntryActivityTest < ActiveSupport::TestCase # Blanking custom field, save should fail e.custom_field_values = { field.id => '' } assert !e.save - refute_empty e.errors[:custom_values] + refute_empty e.errors["custom_field_#{field.id}"] # Update custom field to valid value, save should succeed e.custom_field_values = { field.id => '0' }