box download action switched to warden rescue
This commit is contained in:
parent
afd87c908a
commit
c0121ac08e
|
@ -22,8 +22,6 @@ module Vagrant
|
|||
return if env.error?
|
||||
|
||||
@app.call(@env)
|
||||
|
||||
cleanup
|
||||
end
|
||||
|
||||
def instantiate_downloader
|
||||
|
@ -50,9 +48,9 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
def cleanup
|
||||
def rescue(env)
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|||
@instance.expects(:instantiate_downloader).in_sequence(seq).returns(true)
|
||||
@instance.expects(:download).in_sequence(seq)
|
||||
@app.expects(:call).with(@env).in_sequence(seq)
|
||||
@instance.expects(:cleanup).in_sequence(seq)
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
||||
|
@ -42,7 +41,6 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|||
@instance.expects(:instantiate_downloader).in_sequence(seq).returns(false)
|
||||
@instance.expects(:download).never
|
||||
@app.expects(:call).with(@env).never
|
||||
@instance.expects(:cleanup).never
|
||||
@instance.call(@env)
|
||||
end
|
||||
end
|
||||
|
@ -115,13 +113,13 @@ class DownloadBoxActionTest < Test::Unit::TestCase
|
|||
|
||||
should "delete the temporary file if it exists" do
|
||||
File.expects(:unlink).with(@temp_path).once
|
||||
@instance.cleanup
|
||||
@instance.rescue(@env)
|
||||
end
|
||||
|
||||
should "not delete anything if it doesn't exist" do
|
||||
File.stubs(:exist?).returns(false)
|
||||
File.expects(:unlink).never
|
||||
@instance.cleanup
|
||||
@instance.rescue(@env)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue