diff --git a/CHANGELOG.md b/CHANGELOG.md index c55b1f8e1..013465a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,8 @@ BUG FIXES: - providers/virtualbox: Make more internal interactions with VBoxManage retryable to avoid spurious VirtualBox errors. [GH-2831] - providers/virtualbox: Config validation catches invalid keys. [GH-2843] + - providers/virtualbox: Fix network adapter configuration issue if using + provider-specific config. [GH-2854] - provisioners/chef: When chowning folders, don't follow symlinks. - provisioners/docker: Only add SSH user to docker group if the user isn't already in it. [GH-2838] diff --git a/plugins/providers/virtualbox/config.rb b/plugins/providers/virtualbox/config.rb index c14311d30..19140bac3 100644 --- a/plugins/providers/virtualbox/config.rb +++ b/plugins/providers/virtualbox/config.rb @@ -72,8 +72,8 @@ module VagrantPlugins # # @param [Integer] slot The slot for this network adapter. # @param [Symbol] type The type of adapter. - def network_adapter(slot, type, *args) - @network_adapters[slot] = [type, args] + def network_adapter(slot, type, **opts) + @network_adapters[slot] = [type, opts] end # Shortcut for setting memory size for the virtual machine. diff --git a/test/unit/plugins/providers/virtualbox/config_test.rb b/test/unit/plugins/providers/virtualbox/config_test.rb new file mode 100644 index 000000000..aee442455 --- /dev/null +++ b/test/unit/plugins/providers/virtualbox/config_test.rb @@ -0,0 +1,23 @@ +require_relative "../../../base" + +require Vagrant.source_root.join("plugins/providers/virtualbox/config") + +describe VagrantPlugins::ProviderVirtualBox::Config do + context "defaults" do + before { subject.finalize! } + + it "should have one NAT adapter" do + expect(subject.network_adapters).to eql({ + 1 => [:nat, {}], + }) + end + end + + describe "#network_adapter" do + it "configures additional adapters" do + subject.network_adapter(2, :bridged, auto_config: true) + expect(subject.network_adapters[2]).to eql( + [:bridged, auto_config: true]) + end + end +end diff --git a/test/unit/plugins/providers/virtualbox/synced_folder_test.rb b/test/unit/plugins/providers/virtualbox/synced_folder_test.rb index 20a3fcfd8..592de0955 100644 --- a/test/unit/plugins/providers/virtualbox/synced_folder_test.rb +++ b/test/unit/plugins/providers/virtualbox/synced_folder_test.rb @@ -3,7 +3,6 @@ require Vagrant.source_root.join("test/unit/base") require Vagrant.source_root.join("plugins/providers/virtualbox/synced_folder") -# TODO(mitchellh): tag with v2 describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do let(:machine) do double("machine").tap do |m|