Ticket #1012: puppet-use-template-if-found.patch
| File puppet-use-template-if-found.patch, 1.9 kB (added by adamhjk, 10 months ago) |
|---|
-
a/lib/puppet/module.rb
old new 63 63 return template 64 64 end 65 65 66 # If we can find the template in :templatedir, we return that. 67 td_file = File.join(Puppet.settings.value(:templatedir, environment), template) 68 return td_file if File.exists?(td_file) 69 66 70 path, file = split_path(template) 67 71 68 72 # Because templates don't have an assumed template name, like manifests do, … … 76 80 if mod 77 81 return mod.template(file) 78 82 else 79 return File.join(Puppet.settings.value(:templatedir, environment), template)83 return td_file # Return this anyway, since we're going to fail. 80 84 end 81 85 end 82 86 -
a/spec/unit/other/modules.rb
old new 80 80 File.stubs(:directory?).returns(true) 81 81 Puppet::Module.find_template("mymod/mytemplate").should == "/one/mymod/templates/mytemplate" 82 82 end 83 84 it "should return the file in the templatedir if it exists" do 85 Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates") 86 Puppet[:modulepath] = "/one:/two" 87 File.stubs(:directory?).returns(true) 88 File.stubs(:exists?).returns(true) 89 Puppet::Module.find_template("mymod/mytemplate").should == "/my/templates/mymod/mytemplate" 90 end 83 91 84 92 it "should use the main templatedir if no module is found" do 85 93 Puppet.settings.expects(:value).with(:templatedir, nil).returns("/my/templates")