Commit cd534851 by Jon Yurek

Errors on presence get added to :attachment and :attachment_file_name

parent 61a05368
......@@ -390,7 +390,10 @@ module Paperclip
validates_each :"#{name}_file_name" do |record, attr, value|
if_clause_passed = options[:if].nil? || (options[:if].call(record) != false)
unless_clause_passed = options[:unless].nil? || (!!options[:unless].call(record) == false)
record.errors.add(name, message) if if_clause_passed && unless_clause_passed && value.blank?
if if_clause_passed && unless_clause_passed && value.blank?
record.errors.add(name, message)
record.errors.add("#{name}_file_name", message)
end
end
end
......
......@@ -225,6 +225,7 @@ class PaperclipTest < Test::Unit::TestCase
end
if validation == :presence
should "have an error on the attachment" do
assert @dummy.errors[:avatar]
assert @dummy.errors[:avatar_file_name]
end
else
......
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