Skip to content

Commit

Permalink
Merge pull request ddollar#47 from minhajuddin/master
Browse files Browse the repository at this point in the history
A little convention over configuration love.
  • Loading branch information
ddollar committed Aug 22, 2011
2 parents cf3d7a0 + 64338c5 commit a24c4ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/foreman/export/base.rb
Expand Up @@ -26,6 +26,8 @@ def say(message)
def export_template(exporter, file, template_root)
if template_root && File.exist?(file_path = File.join(template_root, file))
File.read(file_path)
elsif File.exist?(file_path = File.join("~/.foreman/templates", file))
File.read(file_path)
else
File.read(File.expand_path("../../../../data/export/#{exporter}/#{file}", __FILE__))
end
Expand Down
16 changes: 16 additions & 0 deletions spec/foreman/export/upstart_spec.rb
Expand Up @@ -36,4 +36,20 @@
File.read("/tmp/init/app.conf").should == "alternate_template\n"
end
end

context "with alternate templates from home dir" do
let(:default_template_root) {File.expand_path("~/.foreman/templates")}

before do
FileUtils.mkdir_p default_template_root
File.open("#{default_template_root}/master.conf.erb", "w") { |f| f.puts "default_alternate_template" }
end

it "can export with alternate template files" do
upstart.export("/tmp/init")

File.read("/tmp/init/app.conf").should == "default_alternate_template\n"
end
end

end

0 comments on commit a24c4ce

Please sign in to comment.