diff --git a/lib/vagrant/action/builtin/mixin_synced_folders.rb b/lib/vagrant/action/builtin/mixin_synced_folders.rb index 3b5634687..fb0abcce2 100644 --- a/lib/vagrant/action/builtin/mixin_synced_folders.rb +++ b/lib/vagrant/action/builtin/mixin_synced_folders.rb @@ -27,9 +27,11 @@ module Vagrant allowed_types = machine.config.vm.allowed_synced_folder_types if allowed_types - ordered = ordered.select do |_, key, impl| - allowed_types.include? key - end + ordered = allowed_types.map do |type| + ordered.find do |_, key, impl| + key == type + end + end.compact end # Find the proper implementation 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 abfc6f3bd..264e158d2 100644 --- a/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb +++ b/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb @@ -53,6 +53,22 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do result = subject.default_synced_folder_type(machine, plugins) expect(result).to eq("good") end + + it "reprioritizes based on allowed_synced_folder_types" do + plugins = { + "bad" => [impl(false, "bad"), 0], + "good" => [impl(true, "good"), 1], + "same" => [impl(true, "same"), 1], + } + + expect(vm_config).to receive(:allowed_synced_folder_types).and_return(["good", "same"]) + result = subject.default_synced_folder_type(machine, plugins) + expect(result).to eq("good") + + expect(vm_config).to receive(:allowed_synced_folder_types).and_return(["same", "good"]) + result = subject.default_synced_folder_type(machine, plugins) + expect(result).to eq("same") + end end describe "impl_opts" do