Fix crashing bug with `primary_vm` on Environment

This commit is contained in:
Mitchell Hashimoto 2012-02-24 10:27:34 -08:00
parent 50fb129f53
commit 2c823e98bd
3 changed files with 23 additions and 1 deletions

View File

@ -30,6 +30,8 @@
- FreeBSD guests can now have their hostnames changed. [GH-757]
- FreeBSD guests now support host only networking and bridged networking. [GH-762]
- `VM#run_action` is now public so plugin-devs can hook into it.
- Fix crashing bug when attempting to run commands on the "primary"
VM in a multi-VM environment. [GH-761]
## 0.9.7 (February 9, 2012)

View File

@ -138,7 +138,7 @@ module Vagrant
def primary_vm
return vms.values.first if !multivm?
config.vm.defined_vms.each do |name, subvm|
config.global.vm.defined_vms.each do |name, subvm|
return vms[name] if subvm.options[:primary]
end

View File

@ -86,6 +86,26 @@ describe Vagrant::Environment do
end
end
describe "primary VM" do
it "should be the only VM if not a multi-VM environment" do
instance.primary_vm.should == instance.vms.values.first
end
it "should be the VM marked as the primary" do
environment = isolated_environment do |env|
env.vagrantfile(<<-VF)
Vagrant::Config.run do |config|
config.vm.define :foo
config.vm.define :bar, :primary => true
end
VF
end
env = environment.create_vagrant_env
env.primary_vm.should == env.vms[:bar]
end
end
describe "loading configuration" do
it "should load global configuration" do
environment = isolated_environment do |env|