diff --git a/lib/vagrant/plugin/v2/synced_folder.rb b/lib/vagrant/plugin/v2/synced_folder.rb index 851b1ea05..bf02ec2f5 100644 --- a/lib/vagrant/plugin/v2/synced_folder.rb +++ b/lib/vagrant/plugin/v2/synced_folder.rb @@ -29,14 +29,16 @@ module Vagrant c = lambda do |h| h.keys.each do |k| if h[k].is_a?(Hash) - h[k] = c.call(h[k].to_h) + h[k] = c.call(h[k].to_h.clone) end end h end h = c.call(super) h.values.each do |f| - f.delete(:plugin) + f.values.each do |g| + g.delete(:plugin) + end end h end diff --git a/test/unit/vagrant/plugin/v2/synced_folder_test.rb b/test/unit/vagrant/plugin/v2/synced_folder_test.rb new file mode 100644 index 000000000..d02f0eb68 --- /dev/null +++ b/test/unit/vagrant/plugin/v2/synced_folder_test.rb @@ -0,0 +1,46 @@ +require File.expand_path("../../../../base", __FILE__) + +describe Vagrant::Plugin::V2::SyncedFolder::Collection do + include_context "unit" + + let(:folders) { described_class[ + :nfs=> + {"/other"=> + {:type=>:nfs, :guestpath=>"/other", :hostpath=>"/other", :disabled=>false, :__vagrantfile=>true, plugin:"someclass"}, + "/tests"=> + {:type=>:nfs, :guestpath=>"/tests", :hostpath=>"/tests", :disabled=>false, :__vagrantfile=>true, plugin:"someclass"}}, + :virtualbox=> + {"/vagrant"=> + {:guestpath=>"/vagrant", :hostpath=>"/vagrant", :disabled=>false, :__vagrantfile=>true, plugin:"someotherclass"}} + ]} + + describe "#types" do + it "gets all the types of synced folders" do + expect(folders.types).to eq([:nfs, :virtualbox]) + end + end + + describe "#type" do + it "returns the plugin for a type" do + expect(folders.type(:nfs)).to eq("someclass") + expect(folders.type(:virtualbox)).to eq("someotherclass") + end + end + + describe "to_h" do + it "removed plugin key" do + original_folders = folders + folders_h = folders.to_h + folders_h.values.each do |v| + v.values.each do |w| + expect(w).not_to include(:plugin) + end + end + original_folders.values.each do |v| + v.values.each do |w| + expect(w).to include(:plugin) + end + end + end + end +end