summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/type/pfile.rb4
-rwxr-xr-xtest/ral/types/file.rb5
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb
index f86e1e273..7d928d959 100644
--- a/lib/puppet/type/pfile.rb
+++ b/lib/puppet/type/pfile.rb
@@ -460,7 +460,9 @@ module Puppet
super
# Get rid of any duplicate slashes, and remove any trailing slashes.
- @title = @title.gsub(/\/+/, "/").sub(/\/$/, "")
+ @title = @title.gsub(/\/+/, "/")
+
+ @title.sub!(/\/$/, "") unless @title == "/"
# Clean out as many references to any file paths as possible.
# This was the source of many, many bugs.
diff --git a/test/ral/types/file.rb b/test/ral/types/file.rb
index a3a0c579a..aa2e63a89 100755
--- a/test/ral/types/file.rb
+++ b/test/ral/types/file.rb
@@ -1817,5 +1817,10 @@ class TestFile < Test::Unit::TestCase
changes = obj.evaluate
assert(changes.empty?, "Missing file with no ensure resulted in changes")
end
+
+ def test_root_dir_is_named_correctly
+ obj = Puppet::Type.newfile(:path => '/', :mode => 0755)
+ assert_equal("/", obj.title, "/ directory was changed to empty string")
+ end
end