Skip to content

Commit

Permalink
fix difference between behaviour of blank and empty
Browse files Browse the repository at this point in the history
Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
Hemant Kumar authored and josevalim committed Jan 5, 2011
1 parent b7bb795 commit 05da752
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,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")
Expand Down
6 changes: 6 additions & 0 deletions activemodel/test/cases/errors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05da752

Please sign in to comment.