box download action switched to warden rescue

This commit is contained in:
John Bender 2010-07-30 18:16:23 -07:00
parent afd87c908a
commit c0121ac08e
2 changed files with 4 additions and 8 deletions

View File

@ -22,8 +22,6 @@ module Vagrant
return if env.error? return if env.error?
@app.call(@env) @app.call(@env)
cleanup
end end
def instantiate_downloader def instantiate_downloader
@ -50,9 +48,9 @@ module Vagrant
end end
end end
def cleanup def rescue(env)
if temp_path && File.exist?(temp_path) if temp_path && File.exist?(temp_path)
@env.logger.info "Cleaning up downloaded box..." env.logger.info "Cleaning up downloaded box..."
File.unlink(temp_path) File.unlink(temp_path)
end end
end end

View File

@ -32,7 +32,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase
@instance.expects(:instantiate_downloader).in_sequence(seq).returns(true) @instance.expects(:instantiate_downloader).in_sequence(seq).returns(true)
@instance.expects(:download).in_sequence(seq) @instance.expects(:download).in_sequence(seq)
@app.expects(:call).with(@env).in_sequence(seq) @app.expects(:call).with(@env).in_sequence(seq)
@instance.expects(:cleanup).in_sequence(seq)
@instance.call(@env) @instance.call(@env)
end end
@ -42,7 +41,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase
@instance.expects(:instantiate_downloader).in_sequence(seq).returns(false) @instance.expects(:instantiate_downloader).in_sequence(seq).returns(false)
@instance.expects(:download).never @instance.expects(:download).never
@app.expects(:call).with(@env).never @app.expects(:call).with(@env).never
@instance.expects(:cleanup).never
@instance.call(@env) @instance.call(@env)
end end
end end
@ -115,13 +113,13 @@ class DownloadBoxActionTest < Test::Unit::TestCase
should "delete the temporary file if it exists" do should "delete the temporary file if it exists" do
File.expects(:unlink).with(@temp_path).once File.expects(:unlink).with(@temp_path).once
@instance.cleanup @instance.rescue(@env)
end end
should "not delete anything if it doesn't exist" do should "not delete anything if it doesn't exist" do
File.stubs(:exist?).returns(false) File.stubs(:exist?).returns(false)
File.expects(:unlink).never File.expects(:unlink).never
@instance.cleanup @instance.rescue(@env)
end end
end end