From e68994556c638990400d4e5a30422c31b9bf917c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 19 Mar 2010 16:50:54 -0700 Subject: [PATCH] `vagrant reload` uses new Environment --- lib/vagrant/actions/vm/reload.rb | 2 +- lib/vagrant/commands.rb | 6 +++--- test/vagrant/actions/vm/reload_test.rb | 4 +++- test/vagrant/commands_test.rb | 9 +++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/vagrant/actions/vm/reload.rb b/lib/vagrant/actions/vm/reload.rb index 1c3bb08e2..22463dbbf 100644 --- a/lib/vagrant/actions/vm/reload.rb +++ b/lib/vagrant/actions/vm/reload.rb @@ -5,7 +5,7 @@ module Vagrant def prepare steps = [Customize, ForwardPorts, SharedFolders, Boot] steps.unshift(Halt) if @runner.vm.running? - steps << Provision if !Vagrant.config.vm.provisioner.nil? + steps << Provision if !@runner.env.config.vm.provisioner.nil? steps.each do |action_klass| @runner.add_action(action_klass) diff --git a/lib/vagrant/commands.rb b/lib/vagrant/commands.rb index 1b3372df4..1486ae0de 100644 --- a/lib/vagrant/commands.rb +++ b/lib/vagrant/commands.rb @@ -101,9 +101,9 @@ msg # VM, updates the metadata (shared folders, forwarded ports), restarts # the VM, and then reruns the provisioning if enabled. def reload - Env.load! - Env.require_persisted_vm - Env.persisted_vm.execute!(Actions::VM::Reload) + env = Environment.load! + env.require_persisted_vm + env.vm.execute!(Actions::VM::Reload) end # SSH into the vagrant instance. This will setup an SSH connection into diff --git a/test/vagrant/actions/vm/reload_test.rb b/test/vagrant/actions/vm/reload_test.rb index 20a039e3f..b2d77fef1 100644 --- a/test/vagrant/actions/vm/reload_test.rb +++ b/test/vagrant/actions/vm/reload_test.rb @@ -32,11 +32,13 @@ class ReloadActionTest < Test::Unit::TestCase end should "add in the provisioning step if enabled" do - mock_config do |config| + env = mock_environment do |config| # Dummy provisioner to test config.vm.provisioner = "foo" end + @runner.stubs(:env).returns(env) + @default_order.push(Vagrant::Actions::VM::Provision) setup_action_expectations @action.prepare diff --git a/test/vagrant/commands_test.rb b/test/vagrant/commands_test.rb index 6a316d8e0..8e67a3ede 100644 --- a/test/vagrant/commands_test.rb +++ b/test/vagrant/commands_test.rb @@ -107,8 +107,13 @@ class CommandsTest < Test::Unit::TestCase end context "reload" do + should "load the current environment" do + Vagrant::Environment.expects(:load!).once.returns(@env) + Vagrant::Commands.reload + end + should "require a persisted VM" do - Vagrant::Env.expects(:require_persisted_vm).once + @env.expects(:require_persisted_vm).once Vagrant::Commands.reload end @@ -144,7 +149,7 @@ class CommandsTest < Test::Unit::TestCase Vagrant::Environment.expects(:load!).once.returns(@env) Vagrant::Commands.halt end - + should "require a persisted VM" do @env.expects(:require_persisted_vm).once Vagrant::Commands.halt