Commit 7de5e65f by thedarkone Committed by Jon Yurek

Fix how processor's error messages are added to the instance.

(cherry picked from commit 8a5601fbfb878729d9ac92223e282491359a8655)
parent a154479e
...@@ -387,7 +387,8 @@ module Paperclip ...@@ -387,7 +387,8 @@ module Paperclip
def flush_errors #:nodoc: def flush_errors #:nodoc:
@errors.each do |error, message| @errors.each do |error, message|
instance.errors.add(name, message) if message # messages from processors are arrays, so convert everything to an array
Array(message).each {|err_message| instance.errors.add(name, err_message) }
end end
end end
......
...@@ -211,6 +211,22 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -211,6 +211,22 @@ class AttachmentTest < Test::Unit::TestCase
end end
end end
end end
context "An attachment with erroring processor" do
setup do
rebuild_model :processor => [:thumbnail], :styles => { :small => '' }, :whiny_thumbnails => true
@dummy = Dummy.new
Paperclip::Thumbnail.expects(:make).raises(Paperclip::PaperclipError, "cannot be processed.")
@file = StringIO.new("...")
@file.stubs(:to_tempfile).returns(@file)
@dummy.avatar = @file
end
should "correctly forward processing error message to the instance" do
@dummy.valid?
assert_contains @dummy.errors.full_messages, "Avatar cannot be processed."
end
end
context "An attachment with multiple processors" do context "An attachment with multiple processors" do
setup do setup do
......
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