summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/resource/type.rb6
-rwxr-xr-xspec/unit/resource/type.rb10
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index e60f87953..ab57f962f 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -289,7 +289,11 @@ class Puppet::Resource::Type
@namespace = ""
else
@name = name.to_s.downcase
- @namespace, ignored_shortname = namesplit(@name)
+
+ # Note we're doing something somewhat weird here -- we're setting
+ # the class's namespace to its fully qualified name. This means
+ # anything inside that class starts looking in that namespace first.
+ @namespace, ignored_shortname = @type == :hostclass ? [@name, ''] : namesplit(@name)
end
end
diff --git a/spec/unit/resource/type.rb b/spec/unit/resource/type.rb
index 514e6943b..fdb81f760 100755
--- a/spec/unit/resource/type.rb
+++ b/spec/unit/resource/type.rb
@@ -172,8 +172,14 @@ describe Puppet::Resource::Type do
Puppet::Resource::Type.new(:hostclass, "Foo::Bar".intern).name.should == "foo::bar"
end
- it "should set its namespace to the downcased, stringified qualified portion of the name" do
- Puppet::Resource::Type.new(:hostclass, "Foo::Bar::Baz".intern).namespace.should == "foo::bar"
+ it "should set its namespace to the downcased, stringified qualified name for classes" do
+ Puppet::Resource::Type.new(:hostclass, "Foo::Bar::Baz".intern).namespace.should == "foo::bar::baz"
+ end
+
+ [:definition, :node].each do |type|
+ it "should set its namespace to the downcased, stringified qualified portion of the name for #{type}s" do
+ Puppet::Resource::Type.new(type, "Foo::Bar::Baz".intern).namespace.should == "foo::bar"
+ end
end
%w{code line file doc}.each do |arg|