diff --git a/lib/vagrant/action/vm/check_box.rb b/lib/vagrant/action/vm/check_box.rb index e9838a356..2ac0011f9 100644 --- a/lib/vagrant/action/vm/check_box.rb +++ b/lib/vagrant/action/vm/check_box.rb @@ -14,10 +14,17 @@ module Vagrant box_url = env["config"].vm.box_url raise Errors::BoxSpecifiedDoesntExist, :name => box_name if !box_url + # Add the box then reload the box collection so that it becomes + # aware of it. env.ui.info I18n.t("vagrant.actions.vm.check_box.not_found", :name => box_name) Vagrant::Box.add(env.env, box_name, box_url) env["boxes"].reload! - env.env.reload_config! + + # Reload the configuration for all our VMs, since this box + # may be used for other VMs. + env.env.vms.each do |name, vm| + vm.env.reload_config! + end end @app.call(env) diff --git a/test/acceptance/support/output.rb b/test/acceptance/support/output.rb index 79fb292cf..deac8dbdd 100644 --- a/test/acceptance/support/output.rb +++ b/test/acceptance/support/output.rb @@ -66,7 +66,7 @@ module Acceptance # This checks that the "up" output properly contains text showing that # it is downloading the box during the up process. def up_fetching_box(name, vm=DEFAULT_VM) - @text =~ /^[#{vm}] Box #{name} was not found. Fetching box from specified URL...$/ + @text =~ /^\[#{vm}\] Box #{name} was not found. Fetching box from specified URL...$/ end end end diff --git a/test/unit/vagrant/action/vm/check_box_test.rb b/test/unit/vagrant/action/vm/check_box_test.rb index 121554b38..e72ebf9d4 100644 --- a/test/unit/vagrant/action/vm/check_box_test.rb +++ b/test/unit/vagrant/action/vm/check_box_test.rb @@ -40,12 +40,17 @@ class CheckBoxVMActionTest < Test::Unit::TestCase config.vm.box_url = "http://google.com" vf + # Save this for later because the expecations below clobber it + vms = env.env.vms + instance = @klass.new(app, env) seq = sequence("seq") env.env.boxes.expects(:find).returns(nil) Vagrant::Box.expects(:add).with(env.env, env["config"].vm.box, env["config"].vm.box_url).in_sequence(seq) env.env.boxes.expects(:reload!).in_sequence(seq) - env.env.expects(:reload_config!).in_sequence(seq) + vms.each do |name, vm| + vm.env.expects(:reload_config!).in_sequence(seq) + end app.expects(:call).with(env).once.in_sequence(seq) assert_nothing_raised {