diff --git a/lib/vagrant/actions/vm/start.rb b/lib/vagrant/actions/vm/start.rb index 8bf4e4229..42011c968 100644 --- a/lib/vagrant/actions/vm/start.rb +++ b/lib/vagrant/actions/vm/start.rb @@ -8,7 +8,7 @@ module Vagrant steps = [Boot] if !@runner.vm || !@runner.vm.saved? steps.unshift([Customize, ForwardPorts, SharedFolders]) - steps << Provision if !@runner.env.config.vm.provisioner.nil? + steps << Provision if !@runner.env.config.vm.provisioner.nil? && !@runner.created? end steps.flatten.each do |action_klass| diff --git a/test/vagrant/actions/vm/start_test.rb b/test/vagrant/actions/vm/start_test.rb index a7dc8fd24..eeff87950 100644 --- a/test/vagrant/actions/vm/start_test.rb +++ b/test/vagrant/actions/vm/start_test.rb @@ -2,11 +2,12 @@ require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper') class StartActionTest < Test::Unit::TestCase setup do - @mock_vm, @vm, @action = mock_action(Vagrant::Actions::VM::Start) + @runner, @vm, @action = mock_action(Vagrant::Actions::VM::Start) end context "sub-actions" do setup do + @runner.stubs(:created?).returns(false) @vm.stubs(:saved?).returns(true) File.stubs(:file?).returns(true) File.stubs(:exist?).returns(true) @@ -16,7 +17,7 @@ class StartActionTest < Test::Unit::TestCase def setup_action_expectations default_seq = sequence("default_seq") @default_order.flatten.each do |action| - @mock_vm.expects(:add_action).with(action).once.in_sequence(default_seq) + @runner.expects(:add_action).with(action).once.in_sequence(default_seq) end end @@ -33,7 +34,7 @@ class StartActionTest < Test::Unit::TestCase end should "add do additional if VM is not created yet" do - @mock_vm.stubs(:vm).returns(nil) + @runner.stubs(:vm).returns(nil) @default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders]) setup_action_expectations @action.prepare @@ -42,11 +43,21 @@ class StartActionTest < Test::Unit::TestCase should "add provisioning if its enabled and not saved" do @vm.env.config.vm.provisioner = :chef_solo - @mock_vm.stubs(:vm).returns(nil) + @runner.stubs(:vm).returns(nil) @default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders]) @default_order << Vagrant::Actions::VM::Provision setup_action_expectations @action.prepare end + + should "not add provisioning if enabled but already created" do + @runner.stubs(:created?).returns(true) + @vm.env.config.vm.provisioner = :chef_solo + + @runner.stubs(:vm).returns(nil) + @default_order.unshift([Vagrant::Actions::VM::Customize, Vagrant::Actions::VM::ForwardPorts, Vagrant::Actions::VM::SharedFolders]) + setup_action_expectations + @action.prepare + end end end diff --git a/test/vagrant/actions/vm/up_test.rb b/test/vagrant/actions/vm/up_test.rb index a52dcb382..115d90521 100644 --- a/test/vagrant/actions/vm/up_test.rb +++ b/test/vagrant/actions/vm/up_test.rb @@ -7,6 +7,8 @@ class UpActionTest < Test::Unit::TestCase context "sub-actions" do setup do + @runner.stubs(:created?).returns(false) + File.stubs(:file?).returns(true) File.stubs(:exist?).returns(true) @default_order = [Vagrant::Actions::VM::Import, Vagrant::Actions::VM::Start]