fix failing test unit tests

requires to run validations for custom values every time, so we do it

there was no clear indication on why they should not run always, it was not apparent either
pull/2550/head
Jan Sandbrink 10 years ago
parent f945585938
commit 7219eebee5
  1. 2
      lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
  2. 5
      test/unit/time_entry_activity_test.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

@ -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' }

Loading…
Cancel
Save