Commit 2fda5b10 by Michał Szajbe Committed by Jon Yurek

Now Attachment instance is passed as third argument to Processor#make.

(cherry picked from commit e655fbe502fbae2b538922b35c6d2f55b1fee3d1)
parent 35b912ac
......@@ -359,7 +359,7 @@ module Paperclip
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)
Paperclip.processor(processor).make(file, args, self)
end
rescue PaperclipError => e
log("An error was received while processing: #{e.inspect}")
......
......@@ -17,18 +17,19 @@ module Paperclip
# See Paperclip.run for more information about using command-line
# utilities from within Processors.
class Processor
attr_accessor :file, :options
attr_accessor :file, :options, :attachment
def initialize file, options = {}
def initialize file, options = {}, attachment = nil
@file = file
@options = options
@attachment = attachment
end
def make
end
def self.make file, options = {}
new(file, options).make
def self.make file, options = {}, attachment = nil
new(file, options, attachment).make
end
end
......
......@@ -10,7 +10,7 @@ module Paperclip
# unless specified. Thumbnail creation will raise no errors unless
# +whiny+ is true (which it is, by default. If +convert_options+ is
# set, the options will be appended to the convert command upon image conversion
def initialize file, options = {}
def initialize file, options = {}, attachment = nil
super
geometry = options[:geometry]
@file = file
......
......@@ -317,8 +317,13 @@ class AttachmentTest < Test::Unit::TestCase
before_should "call #make on all specified processors" do
expected_params = @style_params[:once].merge({:processors => [:thumbnail, :test], :whiny => nil, :convert_options => ""})
Paperclip::Thumbnail.expects(:make).with(@file, expected_params).returns(@file)
Paperclip::Test.expects(:make).with(@file, expected_params).returns(@file)
Paperclip::Thumbnail.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file)
Paperclip::Test.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file)
end
before_should "call #make with attachment passed as third argument" do
expected_params = @style_params[:once].merge({:processors => [:thumbnail, :test], :whiny => nil, :convert_options => ""})
Paperclip::Test.expects(:make).with(@file, expected_params, @dummy.avatar).returns(@file)
end
end
end
......
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