From 3c9219b8c97e9cbda3134a27da1bb3fe5366d4ae Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 16 Apr 2014 11:20:09 -0700 Subject: [PATCH] core: Builtin SyncedFolders accepts alternate config --- lib/vagrant/action/builtin/synced_folders.rb | 2 +- .../action/builtin/synced_folders_test.rb | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/action/builtin/synced_folders.rb b/lib/vagrant/action/builtin/synced_folders.rb index fe8d5a4f3..efcabaa5a 100644 --- a/lib/vagrant/action/builtin/synced_folders.rb +++ b/lib/vagrant/action/builtin/synced_folders.rb @@ -18,7 +18,7 @@ module Vagrant end def call(env) - folders = synced_folders(env[:machine]) + folders = synced_folders(env[:machine], env[:synced_folders_config]) folders.each do |impl_name, fs| @logger.info("Synced Folder Implementation: #{impl_name}") diff --git a/test/unit/vagrant/action/builtin/synced_folders_test.rb b/test/unit/vagrant/action/builtin/synced_folders_test.rb index e210d04f0..dc434909e 100644 --- a/test/unit/vagrant/action/builtin/synced_folders_test.rb +++ b/test/unit/vagrant/action/builtin/synced_folders_test.rb @@ -3,6 +3,8 @@ require "tmpdir" require File.expand_path("../../../../base", __FILE__) +require Vagrant.source_root.join("plugins/kernel_v2/config/vm") + describe Vagrant::Action::Builtin::SyncedFolders do include_context "unit" include_context "synced folder actions" @@ -96,5 +98,47 @@ describe Vagrant::Action::Builtin::SyncedFolders do expect(ids.length).to eq(2) expect(ids[0]).to eq(ids[1]) end + + it "syncs custom folders" do + ids = [] + order = [] + tracker = Class.new(impl(true, "good")) do + define_method(:prepare) do |machine, folders, opts| + ids << self.object_id + order << :prepare + end + + define_method(:enable) do |machine, folders, opts| + ids << self.object_id + order << :enable + end + end + + plugins[:tracker] = [tracker, 15] + + synced_folders["tracker"] = { + "root" => { + hostpath: "foo", + }, + + "other" => { + hostpath: "bar", + create: true, + } + } + + new_config = double("config") + env[:synced_folders_config] = new_config + + expect(subject).to receive(:synced_folders). + with(machine, new_config). + and_return(synced_folders) + + subject.call(env) + + expect(order).to eq([:prepare, :enable]) + expect(ids.length).to eq(2) + expect(ids[0]).to eq(ids[1]) + end end end