diff options
author | danielsdeleo <dan@opscode.com> | 2013-04-23 15:50:47 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-04-23 15:50:47 -0700 |
commit | 51c5ca1cf9dbdb4a15b64de84f3b6680373e1526 (patch) | |
tree | 384835bee622dd92db8263207d02510af9ea581c | |
parent | 330e7c20c469bf63906439dbd363a5142024de9c (diff) | |
parent | fb71c420844d88495ec1e4a03a0ddbfcfdd5eef8 (diff) | |
download | chef-51c5ca1cf9dbdb4a15b64de84f3b6680373e1526.tar.gz |
Merge branch 'CHEF-4117-10-stable' into 10-stable
-rw-r--r-- | chef/lib/chef/resource.rb | 2 | ||||
-rw-r--r-- | chef/spec/data/lwrp_const_scoping/resources/conflict.rb | 0 | ||||
-rw-r--r-- | chef/spec/unit/lwrp_spec.rb | 9 |
3 files changed, 10 insertions, 1 deletions
diff --git a/chef/lib/chef/resource.rb b/chef/lib/chef/resource.rb index 696cfcd874..22736eae1e 100644 --- a/chef/lib/chef/resource.rb +++ b/chef/lib/chef/resource.rb @@ -731,7 +731,7 @@ F # Add log entry if we override an existing light-weight resource. class_name = convert_to_class_name(rname) - if Chef::Resource.const_defined?(class_name) + if Chef::Resource.const_defined?(class_name, false) Chef::Log.info("#{class_name} light-weight resource already initialized -- overriding!") old_class = Chef::Resource.send(:remove_const, class_name) Chef::Resource.resource_classes.delete(old_class) diff --git a/chef/spec/data/lwrp_const_scoping/resources/conflict.rb b/chef/spec/data/lwrp_const_scoping/resources/conflict.rb new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/chef/spec/data/lwrp_const_scoping/resources/conflict.rb diff --git a/chef/spec/unit/lwrp_spec.rb b/chef/spec/unit/lwrp_spec.rb index 8b0446f375..a787a13dab 100644 --- a/chef/spec/unit/lwrp_spec.rb +++ b/chef/spec/unit/lwrp_spec.rb @@ -18,6 +18,9 @@ require 'spec_helper' +module LwrpConstScopingConflict +end + describe "override logging" do before :each do $stderr.stub!(:write) @@ -61,6 +64,12 @@ describe "override logging" 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.build_from_file("lwrp_const_scoping", conflicting_lwrp_file, nil) + end + end describe "LWRP" do |