The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

puppet-use-template-if-found.patch

Redmine Admin, 01/18/2008 02:30 am

Download (1.93 KB)

View differences:

lib/puppet/module.rb
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

  
spec/unit/other/modules.rb
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")