Skip to content

Commit

Permalink
Add #close, #closed? delegation to AbstractAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
sikachu committed Jun 15, 2012
1 parent e5ed019 commit 2059c5e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/paperclip/io_adapters/abstract_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def path
@tempfile.path
end

def close
@tempfile.close
end

def closed?
@tempfile.closed?
end

private

def destination
Expand Down
25 changes: 24 additions & 1 deletion test/io_adapters/abstract_adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.