No need to reload the VMs hash if has a parent environment.

This commit is contained in:
Mitchell Hashimoto 2010-09-06 00:06:55 -07:00
parent ed48170b24
commit 4342c87473
2 changed files with 20 additions and 5 deletions

View File

@ -81,6 +81,7 @@ module Vagrant
# Returns the VMs associated with this environment.
def vms
return parent.vms if parent
load! if !loaded?
@vms ||= {}
end
@ -275,7 +276,7 @@ module Vagrant
# This environment represents a single sub VM. The VM is then
# probably (read: should be) set on the VM attribute, so we do
# nothing.
return if vm
return if parent
# First load the defaults (blank, noncreated VMs)
load_blank_vms!

View File

@ -306,6 +306,15 @@ class EnvironmentTest < Test::Unit::TestCase
env.expects(:load!).never
env.vms
end
should "return the parent's VMs hash if it has one" do
env = vagrant_env(vagrantfile(<<-vf))
config.vm.define :web
config.vm.define :db
vf
assert env.vms[:web].env.vms.equal?(env.vms)
end
end
context "loading" do
@ -484,10 +493,15 @@ class EnvironmentTest < Test::Unit::TestCase
end
end
should "do nothing if the vm is set" do
@env.stubs(:vm).returns(mock("vm"))
File.expects(:open).never
@env.load_vm!
should "do nothing if the parent is set" do
env = vagrant_env(vagrantfile(<<-vf))
config.vm.define :web
config.vm.define :db
vf
subenv = env.vms[:web].env
subenv.expects(:load_blank_vms!).never
subenv.load_vm!
end
should "uuid should be nil if local data contains nothing" do