Unused config objects are finalized properly [GH-1877]

This commit is contained in:
Mitchell Hashimoto 2013-07-23 13:32:12 -07:00
parent fc7c8b1e99
commit 7ef6c5d9d7
3 changed files with 25 additions and 0 deletions

View File

@ -65,6 +65,7 @@ BUG FIXES:
works properly despite misconfigured sudoers. [GH-1307]
- Synced folder paths on Windows containing '\' are replaced with
'/' internally so that they work properly.
- Unused config objects are finalized properly. [GH-1877]
## 1.2.4 (July 16, 2013)

View File

@ -40,6 +40,12 @@ module Vagrant
# the Vagrant system. The "!" signifies that this is expected to
# mutate itself.
def finalize!
@config_map.each do |key, klass|
if !@keys.has_key?(key)
@keys[key] = klass.new
end
end
@keys.each do |_key, instance|
instance.finalize!
end

View File

@ -41,6 +41,24 @@ describe Vagrant::Config::V2::Root do
}
end
describe "finalization" do
it "should finalize un-used keys" do
foo_class = Class.new do
attr_accessor :foo
def finalize!
@foo = "SET"
end
end
map = { :foo => foo_class }
instance = described_class.new(map)
instance.finalize!
instance.foo.foo.should == "SET"
end
end
describe "validation" do
let(:instance) do
map = { :foo => Object, :bar => Object }