Permalink
Browse files

Keep flash after component is rendered. Closes #2291.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2363 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 72c3ffc commit a111e1a271917c56306b7935677ae212027f7702 Scott Barron committed Sep 27, 2005
View
@@ -1,5 +1,7 @@
*SVN*
+* Keep flash after components are rendered. #2291 [Rick Olson, Scott]
+
* Shorten IE file upload path to filename only to match other browsers. #1507 [court3nay@gmail.com]
* Fix open/save dialog in IE not opening files send with send_file/send_data, #2279 [Thomas Fuchs]
@@ -43,7 +43,9 @@ def render_component_as_string(options) #:doc:
private
def component_response(options, reuse_response = true)
- component_class(options).process(request_for_component(options), reuse_response ? @response : response_for_component)
+ c = component_class(options)
+ c.after_filter {|c| flash.keep }
+ c.process(request_for_component(options), reuse_response ? @response : response_for_component)
end
def component_class(options)
@@ -25,6 +25,14 @@ def internal_callee
render_text "Yes, ma'am"
end
+ def set_flash
+ render_component(:controller => 'callee', :action => 'set_flash')
+ end
+
+ def use_flash
+ render_component(:controller => 'callee', :action => 'use_flash')
+ end
+
def rescue_action(e) raise end
end
@@ -36,6 +44,15 @@ def being_called
def blowing_up
render_text "It's game over, man, just game over, man!", "500 Internal Server Error"
end
+
+ def set_flash
+ flash[:notice] = 'My stoney baby'
+ render :text => 'flash is set'
+ end
+
+ def use_flash
+ render :text => flash[:notice] || 'no flash'
+ end
def rescue_action(e) raise end
end
@@ -71,4 +88,13 @@ def test_internal_calling
get :internal_caller
assert_equal "Are you there? Yes, ma'am", @response.body
end
+
+ def test_flash
+ get :set_flash
+ assert_equal 'My stoney baby', flash[:notice]
+ get :use_flash
+ assert_equal 'My stoney baby', @response.body
+ get :use_flash
+ assert_equal 'no flash', @response.body
+ end
end

0 comments on commit a111e1a

Please sign in to comment.