Permalink
Browse files

Merge pull request #2305 from thedarkone/errors-include

Improve AM::Errors#include?
  • Loading branch information...
2 parents 8faeed1 + efe4cbe commit fa2bfd832c1d1e997d93c2269a485cc74782c86d @spastorino spastorino committed Jul 27, 2011
Showing with 2 additions and 1 deletion.
  1. +1 −1 activemodel/lib/active_model/errors.rb
  2. +1 −0 activemodel/test/cases/errors_test.rb
View
2 activemodel/lib/active_model/errors.rb
@@ -86,7 +86,7 @@ def clear
# Do the error messages include an error with key +error+?
def include?(error)
- messages.include? error
+ (v = messages[error]) && v.any?
end
# Get messages for +key+
View
1 activemodel/test/cases/errors_test.rb
@@ -38,6 +38,7 @@ def test_include?
person.errors[:foo]
assert person.errors.empty?
assert person.errors.blank?
+ assert !person.errors.include?(:foo)
end
test "method validate! should work" do

0 comments on commit fa2bfd8

Please sign in to comment.