diff options
-rw-r--r-- | lib/puppet/file_serving/base.rb | 2 | ||||
-rwxr-xr-x | spec/integration/file_serving/fileset.rb | 14 | ||||
-rwxr-xr-x | spec/integration/file_serving/terminus_helper.rb | 22 | ||||
-rwxr-xr-x | spec/unit/file_serving/base.rb | 5 |
4 files changed, 42 insertions, 1 deletions
diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 9a50833de..c59a54786 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -23,7 +23,7 @@ class Puppet::FileServing::Base # Return the full path to our file. Fails if there's no path set. def full_path - if relative_path.nil? or relative_path == "" + if relative_path.nil? or relative_path == "" or relative_path == "." path else File.join(path, relative_path) diff --git a/spec/integration/file_serving/fileset.rb b/spec/integration/file_serving/fileset.rb new file mode 100755 index 000000000..80bf0f376 --- /dev/null +++ b/spec/integration/file_serving/fileset.rb @@ -0,0 +1,14 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/file_serving/fileset' + +describe Puppet::FileServing::Fileset do + it "should be able to recurse on a single file" do + @path = Tempfile.new("fileset_integration") + + fileset = Puppet::FileServing::Fileset.new(@path.path) + lambda { fileset.files }.should_not raise_error + end +end diff --git a/spec/integration/file_serving/terminus_helper.rb b/spec/integration/file_serving/terminus_helper.rb new file mode 100755 index 000000000..7d2587af1 --- /dev/null +++ b/spec/integration/file_serving/terminus_helper.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/file_serving/terminus_helper' + +class TerminusHelperIntegrationTester + include Puppet::FileServing::TerminusHelper + def model + Puppet::FileServing::Metadata + end +end + +describe Puppet::FileServing::TerminusHelper do + it "should be able to recurse on a single file" do + @path = Tempfile.new("fileset_integration") + request = Puppet::Indirector::Request.new(:metadata, :find, @path.path, :recurse => true) + + tester = TerminusHelperIntegrationTester.new + lambda { tester.path2instances(request, @path.path) }.should_not raise_error + end +end diff --git a/spec/unit/file_serving/base.rb b/spec/unit/file_serving/base.rb index 7cb95aa7a..6a76d81e9 100755 --- a/spec/unit/file_serving/base.rb +++ b/spec/unit/file_serving/base.rb @@ -81,6 +81,11 @@ describe Puppet::FileServing::Base do @file.full_path.should == "/this/file" end + it "should return the path if the relative_path is set to '.'" do + @file.relative_path = "." + @file.full_path.should == "/this/file" + end + it "should return the path joined with the relative path if there is a relative path and it is not set to '/' or ''" do @file.relative_path = "not/qualified" @file.full_path.should == "/this/file/not/qualified" |