Merge pull request #4006 from devton/validation_error_on_message_is_empty_part_2
Fixed bug when error message is an empty string.
This commit is contained in:
commit
05316ba127
|
@ -176,8 +176,9 @@ module ActiveModel
|
|||
end
|
||||
|
||||
# Returns true if no errors are found, false otherwise.
|
||||
# If the error message is a string it can be empty.
|
||||
def empty?
|
||||
all? { |k, v| v && v.empty? }
|
||||
all? { |k, v| v && v.empty? && !v.is_a?(String) }
|
||||
end
|
||||
alias_method :blank?, :empty?
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@ class ValidatesTest < ActiveModel::TestCase
|
|||
PersonWithValidator.reset_callbacks(:validate)
|
||||
end
|
||||
|
||||
def test_validates_with_messages_empty
|
||||
Person.validates :title, :presence => {:message => "" }
|
||||
person = Person.new(:title => '')
|
||||
assert !person.valid?, 'person should not be valid.'
|
||||
end
|
||||
|
||||
def test_validates_with_built_in_validation
|
||||
Person.validates :title, :numericality => true
|
||||
person = Person.new
|
||||
|
|
Loading…
Reference in New Issue