diff options
| author | Luke Kanies <luke@madstop.com> | 2009-08-23 12:10:35 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-08-24 11:34:38 +1000 |
| commit | c0da3bfebb40198703d7d99f2809b315682e28fc (patch) | |
| tree | b58b7ebf1cddc3516049d7b178b010cc2025acac /spec/unit/file_serving/mount/modules.rb | |
| parent | ff39bc707e7f37ddeb28203a9e1bfaddcb9dc641 (diff) | |
| download | puppet-c0da3bfebb40198703d7d99f2809b315682e28fc.tar.gz puppet-c0da3bfebb40198703d7d99f2809b315682e28fc.tar.xz puppet-c0da3bfebb40198703d7d99f2809b315682e28fc.zip | |
Fixing #2558 - propagating recent fileserving changes
I'd made changes to the internals of the fileserving
system to fix #2544 (mostly switched from passing
the node around and then calculating the environment to just
passing the environment around), but those changes weren't consistent
throughout the fileserving code.
In the process of making them consistent, I realized that the
plain file server actually needs the node name rather than
the environment, so I switched to passing the request around,
because it has both pieces of information.
Also added further integration tests which will hopefully keep
this from cropping up again.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/file_serving/mount/modules.rb')
| -rwxr-xr-x | spec/unit/file_serving/mount/modules.rb | 89 |
1 files changed, 40 insertions, 49 deletions
diff --git a/spec/unit/file_serving/mount/modules.rb b/spec/unit/file_serving/mount/modules.rb index 6861e94a5..eeecc9aae 100755 --- a/spec/unit/file_serving/mount/modules.rb +++ b/spec/unit/file_serving/mount/modules.rb @@ -3,70 +3,61 @@ require File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet/file_serving/mount/modules' -describe Puppet::FileServing::Mount::Modules, "when finding files" do +describe Puppet::FileServing::Mount::Modules do before do @mount = Puppet::FileServing::Mount::Modules.new("modules") @environment = stub 'environment', :module => nil - @mount.stubs(:environment).returns @environment + @request = stub 'request', :environment => @environment end - it "should use the node's environment to find the module" do - env = mock 'env' - @mount.expects(:environment).with("mynode").returns env - env.expects(:module) + describe "when finding files" do + it "should use the provided environment to find the module" do + @environment.expects(:module) - @mount.find("foo", :node => "mynode") - end + @mount.find("foo", @request) + end - it "should treat the first field of the relative path as the module name" do - @environment.expects(:module).with("foo") - @mount.find("foo/bar/baz") - end + it "should treat the first field of the relative path as the module name" do + @environment.expects(:module).with("foo") + @mount.find("foo/bar/baz", @request) + end - it "should return nil if the specified module does not exist" do - @environment.expects(:module).with("foo").returns nil - @mount.find("foo/bar/baz") - end + it "should return nil if the specified module does not exist" do + @environment.expects(:module).with("foo").returns nil + @mount.find("foo/bar/baz", @request) + end - it "should return the file path from the module" do - mod = mock 'module' - mod.expects(:file).with("bar/baz").returns "eh" - @environment.expects(:module).with("foo").returns mod - @mount.find("foo/bar/baz").should == "eh" + it "should return the file path from the module" do + mod = mock 'module' + mod.expects(:file).with("bar/baz").returns "eh" + @environment.expects(:module).with("foo").returns mod + @mount.find("foo/bar/baz", @request).should == "eh" + end end -end -describe Puppet::FileServing::Mount::Modules, "when searching for files" do - before do - @mount = Puppet::FileServing::Mount::Modules.new("modules") + describe "when searching for files" do + it "should use the node's environment to search the module" do + @environment.expects(:module) - @environment = stub 'environment', :module => nil - @mount.stubs(:environment).returns @environment - end - - it "should use the node's environment to search the module" do - env = mock 'env' - @mount.expects(:environment).with("mynode").returns env - env.expects(:module) - - @mount.search("foo", :node => "mynode") - end + @mount.search("foo", @request) + end - it "should treat the first field of the relative path as the module name" do - @environment.expects(:module).with("foo") - @mount.search("foo/bar/baz") - end + it "should treat the first field of the relative path as the module name" do + @environment.expects(:module).with("foo") + @mount.search("foo/bar/baz", @request) + end - it "should return nil if the specified module does not exist" do - @environment.expects(:module).with("foo").returns nil - @mount.search("foo/bar/baz") - end + it "should return nil if the specified module does not exist" do + @environment.expects(:module).with("foo").returns nil + @mount.search("foo/bar/baz", @request) + end - it "should return the file path as an array from the module" do - mod = mock 'module' - mod.expects(:file).with("bar/baz").returns "eh" - @environment.expects(:module).with("foo").returns mod - @mount.search("foo/bar/baz").should == ["eh"] + it "should return the file path as an array from the module" do + mod = mock 'module' + mod.expects(:file).with("bar/baz").returns "eh" + @environment.expects(:module).with("foo").returns mod + @mount.search("foo/bar/baz", @request).should == ["eh"] + end end end |
