From e12d96d4df7519c5a1d92748ee2f6952db47efb8 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 31 Dec 2010 02:24:49 -0600 Subject: [PATCH] Only automount NFS folders which have guest path specified --- lib/vagrant/action/vm/nfs.rb | 4 +++- test/vagrant/action/vm/nfs_test.rb | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index 37f633ea1..020036b93 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -113,7 +113,9 @@ module Vagrant def mount_folders @env.ui.info I18n.t("vagrant.actions.vm.nfs.mounting") - @env["vm"].system.mount_nfs(host_ip, folders) + # Only mount the folders which have a guest path specified + am_folders = folders.select { |folder| folder[:guestpath] } + @env["vm"].system.mount_nfs(host_ip, am_folders) end # Returns the IP address of the first host only network adapter diff --git a/test/vagrant/action/vm/nfs_test.rb b/test/vagrant/action/vm/nfs_test.rb index fb59d0dcd..b6f5efcee 100644 --- a/test/vagrant/action/vm/nfs_test.rb +++ b/test/vagrant/action/vm/nfs_test.rb @@ -160,13 +160,19 @@ class NFSVMActionTest < Test::Unit::TestCase context "mounting folders" do setup do @instance.stubs(:host_ip).returns("foo") - @instance.stubs(:folders).returns(["bar"]) + @instance.stubs(:folders).returns([{:guestpath => "foo"}]) end should "mount the folders on the system" do @vm.system.expects(:mount_nfs).with(@instance.host_ip, @instance.folders) @instance.mount_folders end + + should "not mount folders which have no guest path" do + @instance.stubs(:folders).returns([{}]) + @vm.system.expects(:mount_nfs).with(@instance.host_ip, []) + @instance.mount_folders + end end context "getting the host IP" do