summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Campi <andrea.campi@zephirworks.com>2012-11-18 23:44:00 +0100
committerBryan McLellan <btm@opscode.com>2012-12-14 11:10:28 -0800
commit4eb1b589f1d6c216be5788c501c4328a4967ba4b (patch)
treec703b1a2331cdf6df0b27dc16d30c0e7bdd8ee58
parentb8cd17a7e9a2f5e9738400b96df478bab093c7e7 (diff)
downloadchef-4eb1b589f1d6c216be5788c501c4328a4967ba4b.tar.gz
[CHEF-3249] Fix nested partials; add a test for that.
-rw-r--r--lib/chef/mixin/template.rb3
-rw-r--r--spec/data/partial_one.erb1
-rw-r--r--spec/unit/mixin/template_spec.rb8
3 files changed, 11 insertions, 1 deletions
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb
index 9288264fcd..deaf66a509 100644
--- a/lib/chef/mixin/template.rb
+++ b/lib/chef/mixin/template.rb
@@ -36,7 +36,8 @@ class Chef
if variables = options.delete(:variables)
context = {}
context.merge!(variables)
- context[:node] = node
+ context[:node] = @node
+ context[:template_finder] = @template_finder
else
context = self.dup
end
diff --git a/spec/data/partial_one.erb b/spec/data/partial_one.erb
new file mode 100644
index 0000000000..3bbb792092
--- /dev/null
+++ b/spec/data/partial_one.erb
@@ -0,0 +1 @@
+partial one <%= render 'test.erb', :cookbook => 'openldap' %> calling home
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb
index 4b8bcb219f..f5e5181a62 100644
--- a/spec/unit/mixin/template_spec.rb
+++ b/spec/unit/mixin/template_spec.rb
@@ -153,6 +153,14 @@ describe Chef::Mixin::Template, "render_template" do
tmp.open.read.should == "before {super secret is } after"
end
end
+
+ it "should render nested partials" do
+ path = File.expand_path(File.join(CHEF_SPEC_DATA, "partial_one.erb"))
+
+ @provider.render_template("before {<%= render '#{path}', :local => true %>} after", @template_context) do |tmp|
+ tmp.open.read.should == "before {partial one We could be diving for pearls!\n calling home\n} after"
+ end
+ end
end
describe "when an exception is raised in the template" do