Clear shared folders now in the context of a single write lock
This commit is contained in:
parent
60708873e4
commit
f3c44fba2f
|
@ -8,23 +8,17 @@ module Vagrant
|
|||
end
|
||||
|
||||
def call(env)
|
||||
@env = env
|
||||
env["config"].vm.customize do |vm|
|
||||
if vm.shared_folders.length > 0
|
||||
env.ui.info I18n.t("vagrant.actions.vm.clear_shared_folders.deleting")
|
||||
|
||||
clear_shared_folders
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
def clear_shared_folders
|
||||
if @env["vm"].vm.shared_folders.length > 0
|
||||
@env.ui.info I18n.t("vagrant.actions.vm.clear_shared_folders.deleting")
|
||||
|
||||
folders = @env["vm"].vm.shared_folders.dup
|
||||
folders.each do |shared_folder|
|
||||
shared_folder.destroy
|
||||
vm.shared_folders.dup.each do |shared_folder|
|
||||
shared_folder.destroy
|
||||
end
|
||||
end
|
||||
|
||||
@env["vm"].reload!
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,19 +15,11 @@ class ClearSharedFoldersVMActionTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
context "calling" do
|
||||
should "call the proper methods in sequence" do
|
||||
seq = sequence("seq")
|
||||
@instance.expects(:clear_shared_folders).once.in_sequence(seq)
|
||||
@app.expects(:call).with(@env).once
|
||||
@instance.call(@env)
|
||||
end
|
||||
end
|
||||
|
||||
context "clearing shared folders" do
|
||||
setup do
|
||||
@shared_folder = mock("shared_folder")
|
||||
@shared_folders = [@shared_folder]
|
||||
@internal_vm.stubs(:shared_folders).returns(@shared_folders)
|
||||
@env["config"].vm.stubs(:customize).yields(@internal_vm)
|
||||
end
|
||||
|
||||
should "call destroy on each shared folder then reload" do
|
||||
|
@ -36,14 +28,8 @@ class ClearSharedFoldersVMActionTest < Test::Unit::TestCase
|
|||
sf.expects(:destroy).once.in_sequence(destroy_seq)
|
||||
end
|
||||
|
||||
@vm.expects(:reload!).once.in_sequence(destroy_seq)
|
||||
@instance.clear_shared_folders
|
||||
end
|
||||
|
||||
should "do nothing if no shared folders existed" do
|
||||
@shared_folders.clear
|
||||
@vm.expects(:reload!).never
|
||||
@instance.clear_shared_folders
|
||||
@app.expects(:call).with(@env).once
|
||||
@instance.call(@env)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue