Commit 2059c5ea by Prem Sichanugrist

Add #close, #closed? delegation to AbstractAdapter

parent e5ed0191
...@@ -38,6 +38,14 @@ module Paperclip ...@@ -38,6 +38,14 @@ module Paperclip
@tempfile.path @tempfile.path
end end
def close
@tempfile.close
end
def closed?
@tempfile.closed?
end
private private
def destination def destination
......
...@@ -2,7 +2,7 @@ require './test/helper' ...@@ -2,7 +2,7 @@ require './test/helper'
class AbstractAdapterTest < Test::Unit::TestCase class AbstractAdapterTest < Test::Unit::TestCase
class TestAdapter < Paperclip::AbstractAdapter class TestAdapter < Paperclip::AbstractAdapter
attr_accessor :path, :original_file_name attr_accessor :path, :original_file_name, :tempfile
def content_type def content_type
type_from_file_command type_from_file_command
...@@ -18,4 +18,27 @@ class AbstractAdapterTest < Test::Unit::TestCase ...@@ -18,4 +18,27 @@ class AbstractAdapterTest < Test::Unit::TestCase
assert_equal "image/png", TestAdapter.new.content_type assert_equal "image/png", TestAdapter.new.content_type
end end
end end
context "delegation" do
setup do
@adapter = TestAdapter.new
@adapter.tempfile = stub("Tempfile")
end
context "close" do
should "delegate to tempfile" do
@adapter.tempfile.stubs(:close)
@adapter.close
assert_received @adapter.tempfile, :close
end
end
context "closed?" do
should "delegate to tempfile" do
@adapter.tempfile.stubs(:closed?)
@adapter.closed?
assert_received @adapter.tempfile, :closed?
end
end
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