Ben Gribaudo
2006-Dec-14 21:11 UTC
reset_session Clears Flash Contents Before Method Exits
Hello, In the code below, if reset_session is called in action index, flash[:test] is not passed to action special. I would expect that calling reset_session would clear anything in the session/flash which was set before reset_session was called but to have no impact on the storage of anything in the session/flash after it reset_session was called. Interesting..."p flash" in action index reveals that the flash stores appropriate contents after reset_session is called. The clearing of the flash occurs during the redirect. Is this a bug? Thank you, Ben Gribaudo =========Example Code =========class TestController < ActionController::Base def index ## comment this "reset_session" call and flash contents are passed to action special reset_session flash[:test] = ''This should be passed to action special.'' redirect_to :action => ''special'' ## this outputs (to console) the expected contents of the flash p flash end def special unless flash[:test] render :text => "Flash contents cleared." else render :text => "Flash contents maintained." end end end =========Test which should pass if flash contents are maintained. Won''t pass if reset_session is called in action index. =========require ''test/test_helper'' require ''application'' require ''test'' class TestTest < Test::Unit::TestCase def setup @controller = TestController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_ensure_flash_passed get :index assert_equal ''This should be passed to action special.'', flash[:test] assert_redirected_to :action => ''special'' end end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---