summaryrefslogtreecommitdiffstats
path: root/spec/unit/file_serving/mount
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-08-18 15:58:38 -0700
committerLuke Kanies <luke@madstop.com>2009-08-18 15:58:38 -0700
commit796ba5c4ccec117bbc4dec69c670337e70b48634 (patch)
tree549f59c2202da84a3c0d527f4df964bc61c1b6b4 /spec/unit/file_serving/mount
parent6bd3627d606cde4bea9293b855be0dd2b1170a92 (diff)
downloadpuppet-796ba5c4ccec117bbc4dec69c670337e70b48634.tar.gz
puppet-796ba5c4ccec117bbc4dec69c670337e70b48634.tar.xz
puppet-796ba5c4ccec117bbc4dec69c670337e70b48634.zip
Fixing #1544 - plugins in modules now works again
We had to fix the fileserving plumbing to use the request environment instead of trying to use the node environment. This was apparently never fixed after we added the environment to the URI in REST calls. There's still a bit of refactoring left to clean up the APIs used in some of this code. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/file_serving/mount')
-rwxr-xr-xspec/unit/file_serving/mount/plugins.rb30
1 files changed, 11 insertions, 19 deletions
diff --git a/spec/unit/file_serving/mount/plugins.rb b/spec/unit/file_serving/mount/plugins.rb
index ef842d12b..b3a32b70d 100755
--- a/spec/unit/file_serving/mount/plugins.rb
+++ b/spec/unit/file_serving/mount/plugins.rb
@@ -6,65 +6,57 @@ require 'puppet/file_serving/mount/plugins'
describe Puppet::FileServing::Mount::Plugins, "when finding files" do
before do
@mount = Puppet::FileServing::Mount::Plugins.new("modules")
-
- @environment = stub 'environment', :module => nil
- @mount.stubs(:environment).returns @environment
end
- it "should use the node's environment to find the modules" do
+ it "should use the provided environment to find the modules" do
env = mock 'env'
- @mount.expects(:environment).with("mynode").returns env
env.expects(:modules).returns []
- @mount.find("foo", :node => "mynode")
+ @mount.find("foo", env)
end
it "should return nil if no module can be found with a matching plugin" do
mod = mock 'module'
mod.stubs(:plugin).with("foo/bar").returns nil
- @environment.expects(:modules).returns [mod]
- @mount.find("foo/bar").should be_nil
+ env = stub 'env', :modules => []
+ @mount.find("foo/bar", env).should be_nil
end
it "should return the file path from the module" do
mod = mock 'module'
mod.stubs(:plugin).with("foo/bar").returns "eh"
- @environment.expects(:modules).returns [mod]
- @mount.find("foo/bar").should == "eh"
+ env = stub 'env', :modules => [mod]
+ @mount.find("foo/bar", env).should == "eh"
end
end
describe Puppet::FileServing::Mount::Plugins, "when searching for files" do
before do
@mount = Puppet::FileServing::Mount::Plugins.new("modules")
-
- @environment = stub 'environment', :module => nil
- @mount.stubs(:environment).returns @environment
end
it "should use the node's environment to find the modules" do
env = mock 'env'
- @mount.expects(:environment).with("mynode").returns env
env.expects(:modules).returns []
- @mount.search("foo", :node => "mynode")
+ @mount.search("foo", env)
end
it "should return nil if no modules can be found that have plugins" do
mod = mock 'module'
mod.stubs(:plugins?).returns false
- @environment.expects(:modules).returns [mod]
- @mount.search("foo/bar").should be_nil
+ env = stub 'env', :modules => []
+ @mount.search("foo/bar", env).should be_nil
end
it "should return the plugin paths for each module that has plugins" do
one = stub 'module', :plugins? => true, :plugin_directory => "/one"
two = stub 'module', :plugins? => true, :plugin_directory => "/two"
- @environment.expects(:modules).returns [one, two]
- @mount.search("foo/bar").should == %w{/one /two}
+ env = stub 'env', :modules => [one, two]
+ @mount.search("foo/bar", env).should == %w{/one /two}
end
end