diff options
author | danielsdeleo <dan@opscode.com> | 2013-04-23 14:46:03 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-04-23 14:46:03 -0700 |
commit | 9309217a981529a04bab6b2a4387e9adbfe6aa18 (patch) | |
tree | dea752e38552dc0880af88881762322e380ad4f0 | |
parent | a81d760fffcc798ffbfab733ffaa6ec51990e463 (diff) | |
parent | 5f3942e73de403006b8448b992a7f6c8aab2d15a (diff) | |
download | chef-9309217a981529a04bab6b2a4387e9adbfe6aa18.tar.gz |
Merge branch 'CHEF-4117'
-rw-r--r-- | lib/chef/resource/lwrp_base.rb | 2 | ||||
-rw-r--r-- | spec/data/lwrp_const_scoping/resources/conflict.rb | 0 | ||||
-rw-r--r-- | spec/unit/lwrp_spec.rb | 8 |
3 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/resource/lwrp_base.rb b/lib/chef/resource/lwrp_base.rb index 370ccd8c10..5776bb59fb 100644 --- a/lib/chef/resource/lwrp_base.rb +++ b/lib/chef/resource/lwrp_base.rb @@ -39,7 +39,7 @@ class Chef # Add log entry if we override an existing light-weight resource. class_name = convert_to_class_name(rname) - if Resource.const_defined?(class_name) + if Resource.const_defined?(class_name, false) old_class = Resource.send(:remove_const, class_name) # CHEF-3432 -- Chef::Resource keeps a list of subclasses; need to # remove old ones from the list when replacing. diff --git a/spec/data/lwrp_const_scoping/resources/conflict.rb b/spec/data/lwrp_const_scoping/resources/conflict.rb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/spec/data/lwrp_const_scoping/resources/conflict.rb diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 3e807bc06c..19d3504f3c 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -18,6 +18,8 @@ require 'spec_helper' +module LwrpConstScopingConflict +end describe "LWRP" do before do @@ -72,6 +74,12 @@ describe "LWRP" do Chef::Resource.resource_classes.should_not include(first_lwr_foo_class) end + it "does not attempt to remove classes from higher up namespaces [CHEF-4117]" do + conflicting_lwrp_file = File.expand_path( "lwrp_const_scoping/resources/conflict.rb", CHEF_SPEC_DATA) + # The test is that this should not raise an error: + Chef::Resource::LWRPBase.build_from_file("lwrp_const_scoping", conflicting_lwrp_file, nil) + end + end describe "Lightweight Chef::Resource" do |