Commit 454b5ca5 by Jon Yurek

Close all the files! Well, some anyway.

parent 726f183c
......@@ -2,14 +2,9 @@ source "https://rubygems.org"
gemspec
platform :jruby do
gem 'jruby-openssl'
gem 'activerecord-jdbcsqlite3-adapter'
end
platform :ruby do
gem 'pry'
gem 'pry-debugger'
end
gem "jruby-openssl", :platform=>:jruby
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
gem 'pry', :platform=>:ruby
gem 'pry-debugger', :platform=>:ruby
gem "cocaine", :path => "/Users/jyurek/Development/cocaine"
......@@ -429,10 +429,16 @@ module Paperclip
def post_process_style(name, style) #:nodoc:
begin
raise RuntimeError.new("Style #{name} has no processors defined.") if style.processors.blank?
original_file = @queued_for_write[:original]
@queued_for_write[name] = style.processors.inject(@queued_for_write[:original]) do |file, processor|
Paperclip.processor(processor).make(file, style.processor_options, self)
new_file = Paperclip.processor(processor).make(file, style.processor_options, self)
file.close unless file == original_file
new_file
end
unadapted_file = @queued_for_write[name]
@queued_for_write[name] = Paperclip.io_adapters.for(@queued_for_write[name])
unadapted_file.close if unadapted_file.respond_to?(:close)
@queued_for_write[name]
rescue Paperclip::Error => e
log("An error was received while processing: #{e.inspect}")
(@errors[:processing] ||= []) << e.message if @options[:whiny]
......
......@@ -643,7 +643,7 @@ class AttachmentTest < Test::Unit::TestCase
rebuild_model :processors => [:thumbnail, :test], :styles => @style_params
@dummy = Dummy.new
@file = StringIO.new("...")
@file.stubs(:to_tempfile).returns(@file)
@file.stubs(:close)
Paperclip::Test.stubs(:make).returns(@file)
Paperclip::Thumbnail.stubs(:make).returns(@file)
end
......
......@@ -44,7 +44,7 @@ class Test::Unit::TestCase
end
def teardown
report_files
# report_file:
end
def report_files
......@@ -231,3 +231,35 @@ def assert_frame_dimensions(range, frames)
end
end
end
# class File
# def initialize_with_logging(*args)
# if args.first != "/Users/jyurek/.pry_history"
# pp "NEW FILE #{args.inspect}"
# # pp caller
# end
# initialize_without_logging(*args)
# end
# alias_method :initialize_without_logging, :initialize
# alias_method :initialize, :initialize_with_logging
#
# def close_with_logging(*args)
# if path != "/Users/jyurek/.pry_history"
# pp "CLOSE FILE #{self.path}"
# # pp caller
# end
# close_without_logging(*args)
# end
# alias_method :close_without_logging, :close
# alias_method :close, :close_with_logging
# end
#
# class Tempfile
# def initialize_with_logging(*args)
# # pp "NEW #{args.inspect}"
# # pp caller
# initialize_without_logging(*args)
# end
# alias_method :initialize_without_logging, :initialize
# alias_method :initialize, :initialize_with_logging
# end
require './test/helper'
require 'pp'
# 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 AttachmentAdapterTest < Test::Unit::TestCase
def setup
......@@ -37,6 +20,7 @@ class AttachmentAdapterTest < Test::Unit::TestCase
teardown do
@file.close
@subject.close
end
should "get the right filename" do
......@@ -116,6 +100,7 @@ class AttachmentAdapterTest < Test::Unit::TestCase
teardown do
@file.close
@thumb.close
@subject.close
end
should "get the original filename" do
......
......@@ -2,12 +2,6 @@ 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('')
......
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