Commit 6a6f8552 by Matt Patterson Committed by Jon Yurek

Delegate binmode and binmode? in AbstractAdapter

AbstractAdapter wasn't delegating `binmode` or `binmode?` to the
underlying @tempfile object. `binmode` is useful for cases where the
Adapter object gets handed on to another library expecting an `IO`
object holding image data. We ran into this with Prawn and people using
`prawnto` in conjunction with Paperclip. Prawn wants to ensure the `IO`
is in binmode for embedding the image data.
parent 05eb576a
......@@ -5,7 +5,7 @@ module Paperclip
OS_RESTRICTED_CHARACTERS = %r{[/:]}
attr_reader :content_type, :original_filename, :size
delegate :close, :close!, :closed?, :eof?, :path, :rewind, :unlink, :to => :@tempfile
delegate :binmode, :binmode?, :close, :close!, :closed?, :eof?, :path, :rewind, :unlink, :to => :@tempfile
def fingerprint
@fingerprint ||= Digest::MD5.file(path).to_s
......
......@@ -32,7 +32,7 @@ class AbstractAdapterTest < Test::Unit::TestCase
@adapter.tempfile = stub("Tempfile")
end
[:close, :close!, :closed?, :eof?, :path, :rewind, :unlink].each do |method|
[:binmode, :binmode?, :close, :close!, :closed?, :eof?, :path, :rewind, :unlink].each do |method|
should "delegate #{method} to @tempfile" do
@adapter.tempfile.stubs(method)
@adapter.public_send(method)
......
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