diff --git a/lib/vagrant/action/builtin/mixin_synced_folders.rb b/lib/vagrant/action/builtin/mixin_synced_folders.rb index d7b721b0f..d6f2739f2 100644 --- a/lib/vagrant/action/builtin/mixin_synced_folders.rb +++ b/lib/vagrant/action/builtin/mixin_synced_folders.rb @@ -59,12 +59,13 @@ module Vagrant # implementation class for the synced folders. # # @return [Hash>] - def synced_folders(machine) + def synced_folders(machine, config=nil) + config ||= machine.config.vm folders = {} # Determine all the synced folders as well as the implementation # they're going to use. - machine.config.vm.synced_folders.each do |id, data| + config.synced_folders.each do |id, data| # Ignore disabled synced folders next if data[:disabled] diff --git a/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb b/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb index 6c37356fb..7bd5ccbfa 100644 --- a/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb +++ b/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb @@ -88,6 +88,21 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do expect(result[:nfs]).to eq({ "nfs" => folders["nfs"] }) end + it "should return the proper set of folders of a custom config" do + folders["root"] = {} + folders["another"] = {} + + other_folders = { "bar" => {} } + other = double("config") + other.stub(synced_folders: other_folders) + + result = subject.synced_folders(machine, other) + expect(result.length).to eq(1) + expect(result[:default]).to eq({ + "bar" => other_folders["bar"], + }) + end + it "should error if an explicit type is unusable" do plugins[:unusable] = [impl(false, "bad"), 15] folders["root"] = { type: "unusable" }