Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 04a9a83161544437a12175477e37e681fcbc4dd0 1 parent c2c832d
Jon Yurek authored December 30, 2008
8  lib/paperclip/attachment.rb
@@ -326,11 +326,13 @@ def post_process #:nodoc:
326 326
       log("Post-processing #{name}")
327 327
       @styles.each do |name, args|
328 328
         begin
329  
-          @queued_for_write[name] = @queued_for_write[:original]
330  
-          args[:processors].each do |processor|
331  
-            @queued_for_write[name] = Paperclip.processor(processor).make(@queued_for_write[name], args)
  329
+          raise RuntimeError.new("Style #{name} has no processors defined.") if args[:processors].blank?
  330
+          @queued_for_write[name] = args[:processors].inject(@queued_for_write[:original]) do |file, processor|
  331
+            log("Processing #{name} #{file} in the #{processor} processor.")
  332
+            Paperclip.processor(processor).make(file, args)
332 333
           end
333 334
         rescue PaperclipError => e
  335
+          log("An error was received while processing: #{e.inspect}")
334 336
           (@errors[:processing] ||= []) << e.message if @whiny
335 337
         end
336 338
       end
11  test/attachment_test.rb
@@ -210,6 +210,17 @@ class Paperclip::Test < Paperclip::Processor; end
210 210
     end
211 211
   end
212 212
 
  213
+  context "An attachment with no processors defined" do
  214
+    setup do
  215
+      rebuild_model :processors => [], :styles => {:something => 1}
  216
+      @dummy = Dummy.new
  217
+      @file = StringIO.new("...")
  218
+    end
  219
+    should "raise when assigned to" do
  220
+      assert_raises(RuntimeError){ @dummy.avatar = @file }
  221
+    end
  222
+  end
  223
+
213 224
   context "Assigning an attachment with post_process hooks" do
214 225
     setup do
215 226
       rebuild_model :styles => { :something => "100x100#" }

0 notes on commit 04a9a83

Please sign in to comment.
Something went wrong with that request. Please try again.