Merge pull request #11897 from opf/fix/comment-validates-wp-changes

docs-add-details-follow-precede-gantt-distance-2
Oliver Günther 2 years ago committed by GitHub
commit 213f4063c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/custom_value.rb
  2. 3
      lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
  3. 11
      spec/models/work_package/work_package_acts_as_customizable_spec.rb

@ -61,6 +61,10 @@ class CustomValue < ApplicationRecord
end
end
def default?
value == custom_field.default_value
end
protected
def validate_presence_of_required_value

@ -256,6 +256,9 @@ module Redmine
# Skip when the old value equals the new value (no change happened).
next cfv_changes if value_was == cfv.value
# Skip when the new value is the default value
next cfv_changes if value_was.nil? && cfv.default?
cfv_changes.merge("custom_field_#{cfv.custom_field_id}": [value_was, cfv.value])
end
end

@ -135,5 +135,16 @@ describe WorkPackage, 'acts_as_customizable' do
before do
setup_custom_field(custom_field)
end
context 'with a default value' do
before do
custom_field.update! default_value: 'foobar'
model_instance.custom_values.destroy_all
end
it 'returns no changes' do
expect(model_instance.custom_field_changes).to be_empty
end
end
end
end

Loading…
Cancel
Save