Commit fb13e2ec by Jon Yurek

Print all the files!

parent 14469310
......@@ -11,3 +11,5 @@ platform :ruby do
gem 'pry'
gem 'pry-debugger'
end
gem "cocaine", :path => "/Users/jyurek/Development/cocaine"
......@@ -8,6 +8,7 @@ class ContentTypeDetectorTest < Test::Unit::TestCase
should 'return the empty content type when the file is empty' do
tempfile = Tempfile.new("empty")
assert_equal "inode/x-empty", Paperclip::ContentTypeDetector.new(tempfile.path).detect
tempfile.close
end
should 'return content type of file if it is an acceptable type' do
......
......@@ -7,6 +7,8 @@ class FileCommandContentTypeDetectorTest < Test::Unit::TestCase
tempfile.rewind
assert_equal "text/plain", Paperclip::FileCommandContentTypeDetector.new(tempfile.path).detect
tempfile.close
end
should 'return a sensible default when the file command is missing' do
......
......@@ -41,6 +41,10 @@ class Test::Unit::TestCase
Rails.stubs(:const_defined?).with(:Railtie).returns(false)
end
end
def report_files
ObjectSpace.each_object(IO){|io| puts "Open IO: #{io.inspect}" unless io.closed? }
end
end
$LOAD_PATH << File.join(ROOT, 'lib')
......
......@@ -7,6 +7,10 @@ class AttachmentAdapterTest < Test::Unit::TestCase
@attachment = Dummy.new.avatar
end
def teardown
report_files
end
context "for an attachment" do
setup do
@file = File.new(fixture_file("5k.png"))
......@@ -18,6 +22,7 @@ class AttachmentAdapterTest < Test::Unit::TestCase
end
teardown do
@subject.close
@file.close
end
......
require './test/helper'
class DataUriAdapterTest < Test::Unit::TestCase
def teardown
if @subject
@subject.close
end
end
context "a new instance" do
setup do
@contents = "data:image/png;base64,#{original_base64_content}"
......
require './test/helper'
class EmptyStringAdapterTest < Test::Unit::TestCase
def teardown
if @subject
@subject.close
end
end
context 'a new instance' do
setup do
@subject = Paperclip.io_adapters.for('')
......
require './test/helper'
class File
def initialize_with_logging(*args)
p "NEW FILE #{args.inspect}"
p caller
initialize_without_logging(*args)
end
alias_method :initialize_without_logging, :initialize
alias_method :initialize, :initialize_with_logging
end
# class Tempfile
# def initialize_with_logging(*args)
# p "NEW #{args.inspect}"
# initialize_without_logging(*args)
# end
# alias_method :initialize_without_logging, :initialize
# alias_method :initialize, :initialize_with_logging
# end
class FileAdapterTest < Test::Unit::TestCase
def setup
p self
end
def teardown
report_files
end
context "a new instance" do
context "with normal file" do
setup do
......@@ -9,7 +33,10 @@ class FileAdapterTest < Test::Unit::TestCase
@subject = Paperclip.io_adapters.for(@file)
end
teardown { @file.close }
teardown do
@file.close
@subject.close
end
should "get the right filename" do
assert_equal "5k.png", @subject.original_filename
......@@ -86,13 +113,17 @@ class FileAdapterTest < Test::Unit::TestCase
context "filename with restricted characters" do
setup do
file_contents = File.new(fixture_file("animated.gif"))
@file = StringIO.new(file_contents.read)
@file = File.open(fixture_file("animated.gif")) do |file|
StringIO.new(file.read)
end
@file.stubs(:original_filename).returns('image:restricted.gif')
@subject = Paperclip.io_adapters.for(@file)
end
teardown { @file.close }
teardown do
@file.close
@subject.close
end
should "not generate filenames that include restricted characters" do
assert_equal 'image_restricted.gif', @subject.original_filename
......@@ -109,7 +140,10 @@ class FileAdapterTest < Test::Unit::TestCase
@subject = Paperclip.io_adapters.for(@file)
end
teardown { @file.close }
teardown do
@file.close
@subject.close
end
should "provide correct mime-type" do
assert_match %r{.*/x-empty}, @subject.content_type
......
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