From a111e1a271917c56306b7935677ae212027f7702 Mon Sep 17 00:00:00 2001 From: Scott Barron Date: Tue, 27 Sep 2005 11:02:11 +0000 Subject: Keep flash after component is rendered. Closes #2291. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2363 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/components_test.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'actionpack/test') diff --git a/actionpack/test/controller/components_test.rb b/actionpack/test/controller/components_test.rb index bf6f246702..b1aa80304c 100644 --- a/actionpack/test/controller/components_test.rb +++ b/actionpack/test/controller/components_test.rb @@ -25,6 +25,14 @@ class CallerController < ActionController::Base 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 @@ class CalleeController < ActionController::Base 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 @@ class ComponentsTest < Test::Unit::TestCase 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 \ No newline at end of file -- cgit v1.2.3