Commit 04a9a831 by Jon Yurek

Fixed a bug where errors in processing would create further errors in attachment…

Fixed a bug where errors in processing would create further errors in attachment saving. Will also raise if there are no processors defined for a style.
parent c2c832d9
......@@ -326,11 +326,13 @@ module Paperclip
log("Post-processing #{name}")
@styles.each do |name, args|
begin
@queued_for_write[name] = @queued_for_write[:original]
args[:processors].each do |processor|
@queued_for_write[name] = Paperclip.processor(processor).make(@queued_for_write[name], args)
raise RuntimeError.new("Style #{name} has no processors defined.") if args[:processors].blank?
@queued_for_write[name] = args[:processors].inject(@queued_for_write[:original]) do |file, processor|
log("Processing #{name} #{file} in the #{processor} processor.")
Paperclip.processor(processor).make(file, args)
end
rescue PaperclipError => e
log("An error was received while processing: #{e.inspect}")
(@errors[:processing] ||= []) << e.message if @whiny
end
end
......
......@@ -210,6 +210,17 @@ class AttachmentTest < Test::Unit::TestCase
end
end
context "An attachment with no processors defined" do
setup do
rebuild_model :processors => [], :styles => {:something => 1}
@dummy = Dummy.new
@file = StringIO.new("...")
end
should "raise when assigned to" do
assert_raises(RuntimeError){ @dummy.avatar = @file }
end
end
context "Assigning an attachment with post_process hooks" do
setup do
rebuild_model :styles => { :something => "100x100#" }
......
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