diff options
author | Nick Lewis <nick@puppetlabs.com> | 2011-05-03 16:18:57 -0700 |
---|---|---|
committer | Nick Lewis <nick@puppetlabs.com> | 2011-05-03 16:18:57 -0700 |
commit | 90eb937a093b6dd962ee136a4e6f84cfa3ba72cd (patch) | |
tree | b87d09c1b1f3ed8bcc758cbdbe3757de4dc64bb6 | |
parent | 37c86dd466aa571b0194b06bbf4d21ffb007c8be (diff) | |
download | puppet-90eb937a093b6dd962ee136a4e6f84cfa3ba72cd.tar.gz puppet-90eb937a093b6dd962ee136a4e6f84cfa3ba72cd.tar.xz puppet-90eb937a093b6dd962ee136a4e6f84cfa3ba72cd.zip |
(#7139) Accept '/' as a valid path in filesets
This was unconditionally removing the trailing file separator ('/'), which is
only valid when the file separator isn't the entire path. This fixes 'puppet
resource file <path>'.
Paired-With: Jacob Helwig
-rw-r--r-- | lib/puppet/file_serving/fileset.rb | 2 | ||||
-rwxr-xr-x | spec/unit/file_serving/fileset_spec.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index c020f036d..f29f70a53 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -59,7 +59,7 @@ class Puppet::FileServing::Fileset end def initialize(path, options = {}) - path = path.chomp(File::SEPARATOR) + path = path.chomp(File::SEPARATOR) unless path == File::SEPARATOR raise ArgumentError.new("Fileset paths must be fully qualified") unless File.expand_path(path) == path @path = path diff --git a/spec/unit/file_serving/fileset_spec.rb b/spec/unit/file_serving/fileset_spec.rb index 149c68c4a..6b41e8a74 100755 --- a/spec/unit/file_serving/fileset_spec.rb +++ b/spec/unit/file_serving/fileset_spec.rb @@ -21,6 +21,13 @@ describe Puppet::FileServing::Fileset, " when initializing" do fileset.path.should == path end + it "should not fail if the path is just the file separator" do + path = File::SEPARATOR + File.stubs(:lstat).with(path).returns stub('stat') + fileset = Puppet::FileServing::Fileset.new(path) + fileset.path.should == path + end + it "should fail if its path does not exist" do File.expects(:lstat).with("/some/file").returns nil proc { Puppet::FileServing::Fileset.new("/some/file") }.should raise_error(ArgumentError) |