Commit 93f4f3cd by Jon Yurek

#67 Fixed passing validations still existing in errors hash.

parent c751827d
...@@ -117,7 +117,7 @@ module Paperclip ...@@ -117,7 +117,7 @@ module Paperclip
# Returns true if there are no errors on this attachment. # Returns true if there are no errors on this attachment.
def valid? def valid?
validate validate
errors.length == 0 errors.empty?
end end
# Returns an array containing the errors on this attachment. # Returns an array containing the errors on this attachment.
...@@ -235,6 +235,7 @@ module Paperclip ...@@ -235,6 +235,7 @@ module Paperclip
errors[name] = block.call(self, instance) if block errors[name] = block.call(self, instance) if block
errors errors
end end
@validation_errors.reject!{|k,v| v == nil }
@errors.merge!(@validation_errors) @errors.merge!(@validation_errors)
end end
@validation_errors @validation_errors
......
...@@ -147,7 +147,7 @@ class PaperclipTest < Test::Unit::TestCase ...@@ -147,7 +147,7 @@ class PaperclipTest < Test::Unit::TestCase
@dummy.valid? @dummy.valid?
end end
should "not have an error when assigned a valid file" do should "not have an error when assigned a valid file" do
assert_nil @dummy.avatar.errors[validation] assert ! @dummy.avatar.errors.key?(validation)
end end
should "not have an error on the attachment" do should "not have an error on the attachment" do
assert_nil @dummy.errors.on(:avatar) assert_nil @dummy.errors.on(:avatar)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment