jrgifford / delayed_paperclip

Process your Paperclip attachments in the background with delayed_job or Resque.
http://www.jstorimer.com/ruby/2010/01/30/delayed-paperclip.html
MIT License
402 stars 155 forks source link

Unable to use non-delayed attachment with validate_attachment_size matcher #105

Closed aripollak closed 9 years ago

aripollak commented 10 years ago

We're currently using the validate_attachment_size matcher in our tests, but after upgrading delayed_paperclip to 2.8.0 and paperclip 4.2.0, this no longer works for images that are not marked as process_in_background. It looks like this is related to the matcher setting post_processing = false.

So if I had a model that just contained this, with the delayed_paperclip gem loaded:

class Announcement < ActiveRecord::Base
  has_attached_file :image
end

and then tried to run this in a console:

a = Announcement.new
a.image.post_processing = false
a.image = StringIO.new

I get this error:

NoMethodError: undefined method `[]' for nil:NilClass
    from /home/ari/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/delayed_paperclip-2.8.0/lib/delayed_paperclip/attachment.rb:40:in `split_processing?'
    from /home/ari/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/delayed_paperclip-2.8.0/lib/delayed_paperclip/attachment.rb:20:in `post_processing_with_delay'
    from /home/ari/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/paperclip-4.2.0/lib/paperclip/attachment.rb:458:in `post_process_file'
    from /home/ari/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/paperclip-4.2.0/lib/paperclip/attachment.rb:107:in `assign'
    from /home/ari/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/paperclip-4.2.0/lib/paperclip/has_attached_file.rb:66:in `block in define_setter'
jessieay commented 10 years ago

+1, we are seeing this too. Seems like this is a change that should be made to the matcher on Paperclip, not to delayed paperclip?

aripollak commented 10 years ago

I should note that keeping delayed_paperclip at 2.6.1 and upgrading paperclip to 4.2.0 still works at this point.