1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixed bug when error message is an empty string.

This commit is contained in:
Antonio Roberto 2011-12-16 17:17:14 -02:00
parent f307f4d884
commit 66e747b461
2 changed files with 8 additions and 1 deletions

View file

@ -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?

View file

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