Skip to content
Browse files

Add #close, #closed? delegation to AbstractAdapter

  • Loading branch information...
1 parent e5ed019 commit 2059c5ea2e7a3ce044c52c3f971a4fc9f374e559 @sikachu sikachu committed Jun 15, 2012
Showing with 32 additions and 1 deletion.
  1. +8 −0 lib/paperclip/io_adapters/abstract_adapter.rb
  2. +24 −1 test/io_adapters/abstract_adapter_test.rb
View
8 lib/paperclip/io_adapters/abstract_adapter.rb
@@ -38,6 +38,14 @@ def path
@tempfile.path
end
+ def close
+ @tempfile.close
+ end
+
+ def closed?
+ @tempfile.closed?
+ end
+
private
def destination
View
25 test/io_adapters/abstract_adapter_test.rb
@@ -2,7 +2,7 @@
class AbstractAdapterTest < Test::Unit::TestCase
class TestAdapter < Paperclip::AbstractAdapter
- attr_accessor :path, :original_file_name
+ attr_accessor :path, :original_file_name, :tempfile
def content_type
type_from_file_command
@@ -18,4 +18,27 @@ def content_type
assert_equal "image/png", TestAdapter.new.content_type
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

0 comments on commit 2059c5e

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