Only run Environment#load! once

This commit is contained in:
Mitchell Hashimoto 2010-09-07 00:07:22 -07:00
parent 1478818939
commit 84389580d6
2 changed files with 13 additions and 9 deletions

View File

@ -206,11 +206,14 @@ module Vagrant
# such as `vm`, `config`, etc. on this environment. The order this # such as `vm`, `config`, etc. on this environment. The order this
# method calls its other methods is very particular. # method calls its other methods is very particular.
def load! def load!
@loaded = true if !loaded?
self.class.check_virtualbox! @loaded = true
load_config! self.class.check_virtualbox!
load_vm! load_config!
actions.run(:environment_load) load_vm!
actions.run(:environment_load)
end
self self
end end

View File

@ -318,12 +318,13 @@ class EnvironmentTest < Test::Unit::TestCase
context "overall load method" do context "overall load method" do
should "load! should call proper sequence and return itself" do should "load! should call proper sequence and return itself" do
env = @klass.new(:cwd => vagrantfile)
call_seq = sequence("call_sequence") call_seq = sequence("call_sequence")
@klass.expects(:check_virtualbox!).once.in_sequence(call_seq) @klass.expects(:check_virtualbox!).once.in_sequence(call_seq)
@env.expects(:load_config!).once.in_sequence(call_seq) env.expects(:load_config!).once.in_sequence(call_seq)
@env.expects(:load_vm!).once.in_sequence(call_seq) env.expects(:load_vm!).once.in_sequence(call_seq)
@env.actions.expects(:run).with(:environment_load).once.in_sequence(call_seq) env.actions.expects(:run).with(:environment_load).once.in_sequence(call_seq)
assert_equal @env, @env.load! assert_equal env, env.load!
end end
end end