Permalink
Browse files

fix difference between behaviour of blank and empty

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
Hemant Kumar authored and josevalim committed Jan 5, 2011
1 parent 5c66677 commit 8de5595e4d101a53f33ae8c48837855d8594f320
Showing with 7 additions and 1 deletion.
  1. +1 −1 activemodel/lib/active_model/errors.rb
  2. +6 −0 activemodel/test/cases/errors_test.rb
@@ -147,7 +147,7 @@ def count
def empty?
all? { |k, v| v && v.empty? }
end
-
+ alias_method :blank?, :empty?
# Returns an xml formatted representation of the Errors hash.
#
# p.errors.add(:name, "can't be blank")
@@ -25,7 +25,13 @@ def self.human_attribute_name(attr, options = {})
def self.lookup_ancestors
[self]
end
+ end
+ test "should return true if no errors" do
+ person = Person.new
+ person.errors[:foo]
+ assert person.errors.empty?
+ assert person.errors.blank?
end
test "method validate! should work" do

0 comments on commit 8de5595

Please sign in to comment.