Commit 748332eb by Daniel Evans Committed by Prem Sichanugrist

Cleaning up the downloaded original file if it is a tempfile, such as it is with s3 storage.

parent e526c86a
......@@ -291,6 +291,7 @@ module Paperclip
post_process(*style_args)
old_original.close if old_original.respond_to?(:close)
old_original.unlink if old_original.respond_to?(:unlink)
save
else
......
......@@ -71,6 +71,22 @@ class IntegrationTest < Test::Unit::TestCase
should "change the timestamp" do
assert_not_equal @original_timestamp, @d2.avatar_updated_at
end
should "clean up the old original if it is a tempfile" do
original = @d2.avatar.to_file(:original)
tf = Paperclip::Tempfile.new('original')
tf.binmode
original.binmode
tf.write(original.read)
original.close
tf.rewind
File.expects(:unlink).with(tf.instance_variable_get(:@tmpname))
@d2.avatar.expects(:to_file).with(:original).returns(tf)
@d2.avatar.reprocess!
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