From cf32abb210352c5b736484cfed836767c2684f8c Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 3 Aug 2010 19:43:39 -0700 Subject: [PATCH] `vagrant up` can be used the same as `vagrant resume` [closes GH-134] --- CHANGELOG.md | 2 ++ lib/vagrant/vm.rb | 1 + test/vagrant/vm_test.rb | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6825356e..28b0b2379 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.5.2 (unreleased) + - `vagrant up` can be used as a way to resume the VM as well (same as + `vagrant resume`). [GH-134] - Sudo uses "-E" flag to preserve environment for chef provisioners. This fixes issues with CentOS. [GH-133] - Added "IdentitiesOnly yes" to options when `vagrant ssh` is run to diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index d9a00043d..61830deb8 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -103,6 +103,7 @@ module Vagrant def start return if @vm.running? + return resume if @vm.saved? env.actions.run(:start) end diff --git a/test/vagrant/vm_test.rb b/test/vagrant/vm_test.rb index 8d62c40b8..c9af61d14 100644 --- a/test/vagrant/vm_test.rb +++ b/test/vagrant/vm_test.rb @@ -203,6 +203,7 @@ class VMTest < Test::Unit::TestCase context "starting" do setup do @mock_vm.stubs(:running?).returns(false) + @mock_vm.stubs(:saved?).returns(false) end should "not do anything if the VM is already running" do @@ -211,6 +212,13 @@ class VMTest < Test::Unit::TestCase @vm.start end + should "execute the resume action if saved" do + @mock_vm.expects(:saved?).returns(true) + @vm.expects(:resume).once + @vm.env.actions.expects(:run).with(:start).never + @vm.start + end + should "execute the start action" do @vm.env.actions.expects(:run).with(:start).once @vm.start