aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2005-10-25 02:15:08 +0000
committerNicholas Seckar <nseckar@gmail.com>2005-10-25 02:15:08 +0000
commit86a571090c43cd00284e563b63a79016acc2f18b (patch)
tree60aaab23ade94c51ae76551691476075986bf963
parent3a2943c54de7e288ac2443556257df7b2d69ac68 (diff)
downloadrails-86a571090c43cd00284e563b63a79016acc2f18b.tar.gz
rails-86a571090c43cd00284e563b63a79016acc2f18b.tar.bz2
rails-86a571090c43cd00284e563b63a79016acc2f18b.zip
Reset template variables after using render_to_string. Closes #2559
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2723 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/base.rb2
-rw-r--r--actionpack/test/controller/render_test.rb9
-rw-r--r--actionpack/test/fixtures/test/render_to_string_test.rhtml1
4 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 31882ce0dd..028e7e7866 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Reset template variables after using render_to_string [skaes@web.de]
+
* Expose the session model backing CGI::Session
* Abbreviate RAILS_ROOT in traces
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 067dcacca6..b338904142 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -623,6 +623,8 @@ module ActionController #:nodoc:
def render_to_string(options = nil) #:doc:
result = render(options)
erase_render_results
+ @variables_added = nil
+ @template.instance_variable_set("@assigns_added", nil)
result
end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 9894a70755..fe59035cf4 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -89,6 +89,10 @@ class TestController < ActionController::Base
ActionView::Base.local_assigns_support_string_keys = false
end
+ def render_to_string_test
+ @foo = render_to_string :inline => "this is a test"
+ end
+
def rescue_action(e) raise end
private
@@ -209,6 +213,11 @@ class RenderTest < Test::Unit::TestCase
assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", process_request.body
end
+ def test_render_to_string_resets_assigns
+ @request.action = "render_to_string_test"
+ assert_equal "The value of foo is: ::this is a test::\n", process_request.body
+ end
+
def test_nested_rendering
@request.action = "hello_world"
assert_equal "Living in a nested world", Fun::GamesController.process(@request, @response).body
diff --git a/actionpack/test/fixtures/test/render_to_string_test.rhtml b/actionpack/test/fixtures/test/render_to_string_test.rhtml
new file mode 100644
index 0000000000..6e267e8634
--- /dev/null
+++ b/actionpack/test/fixtures/test/render_to_string_test.rhtml
@@ -0,0 +1 @@
+The value of foo is: ::<%= @foo %>::