diff options
author | danielsdeleo <dan@opscode.com> | 2013-04-23 15:50:47 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-04-23 15:54:31 -0700 |
commit | c1f1aba870f3de147a5d2f4a822db51250b92aa4 (patch) | |
tree | da7eb3ce68951884bd9384ec37af8495cc4ed299 | |
parent | 8ed43e516e8aaf0b24348087e485ea60fd9a9d97 (diff) | |
download | chef-c1f1aba870f3de147a5d2f4a822db51250b92aa4.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 |