aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/base.rb3
-rw-r--r--actionpack/test/controller/new_render_test.rb19
3 files changed, 23 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 3f85c38106..792480750c 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Ensure that the instance variables are copied to the template when performing render :update. [Nicholas Seckar]
+
* Add the ability to call JavaScriptGenerator methods from helpers called in update blocks. [Sam Stephenson] Example:
module ApplicationHelper
def update_time
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 43f948e73d..862d2e5efd 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -642,6 +642,9 @@ module ActionController #:nodoc:
end
elsif options[:update]
+ add_variables_to_assigns
+ @template.send :evaluate_assigns
+
generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(@template, &block)
render_javascript(generator.to_s)
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index 0208912ece..997a49091d 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -194,6 +194,15 @@ class NewRenderTestController < ActionController::Base
page.visual_effect :highlight, 'balance'
end
end
+
+ def update_page_with_instance_variables
+ @money = '$37,000,000.00'
+ @div_id = 'balance'
+ render :update do |page|
+ page.replace_html @div_id, @money
+ page.visual_effect :highlight, @div_id
+ end
+ end
def action_talk_to_layout
# Action template sets variable that's picked up by layout
@@ -223,7 +232,7 @@ class NewRenderTestController < ActionController::Base
"render_with_explicit_template",
"render_js_with_explicit_template",
"render_js_with_explicit_action_template",
- "delete_with_js", "update_page"
+ "delete_with_js", "update_page", "update_page_with_instance_variables"
"layouts/standard"
when "builder_layout_test"
@@ -494,6 +503,14 @@ class NewRenderTest < Test::Unit::TestCase
assert_equal 2, @response.body.split($/).length
end
+ def test_update_page_with_instance_variables
+ get :update_page_with_instance_variables
+ assert_template nil
+ assert_equal 'text/javascript', @response.headers['Content-Type']
+ assert_match /balance/, @response.body
+ assert_match /\$37/, @response.body
+ end
+
def test_yield_content_for
get :yield_content_for
assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!\n", @response.body