diff --git a/lib/paperclip/attachment.rb b/lib/paperclip/attachment.rb index 7460e6550..361b7dc0d 100644 --- a/lib/paperclip/attachment.rb +++ b/lib/paperclip/attachment.rb @@ -326,11 +326,13 @@ def post_process #:nodoc: 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 diff --git a/test/attachment_test.rb b/test/attachment_test.rb index bf93904d8..fc2beb88d 100644 --- a/test/attachment_test.rb +++ b/test/attachment_test.rb @@ -210,6 +210,17 @@ class Paperclip::Test < Paperclip::Processor; end 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#" }