diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2012-04-30 00:16:10 -0700 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-04-30 00:16:10 -0700 |
commit | 88b5f943e67745e38b903d4a4cb0afe121b46857 (patch) | |
tree | f2b845cf9c9b02bf4b6ce3175c447664b39228d2 | |
parent | 4cff1a28095ca93f865eaaa7b4ce0132b5256340 (diff) | |
parent | 5638adfd87dbec20183443204793c1de41ee9bb7 (diff) | |
download | rails-88b5f943e67745e38b903d4a4cb0afe121b46857.tar.gz rails-88b5f943e67745e38b903d4a4cb0afe121b46857.tar.bz2 rails-88b5f943e67745e38b903d4a4cb0afe121b46857.zip |
Merge pull request #6034 from willbryant/flash_must_not_load_session_on_every_request_master
Fix the Flash middleware loading the session on every request
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/flash.rb | 9 |
2 files changed, 3 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index d2581296cf..21997c4d79 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -479,7 +479,6 @@ module ActionController @request.session.update(session) if session @request.session["flash"] = @request.flash.update(flash || {}) - @request.session["flash"].sweep @controller.request = @request build_request_uri(action, parameters) diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index c92c91df65..54f2669f43 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -4,7 +4,7 @@ module ActionDispatch # read a notice you put there or <tt>flash["notice"] = "hello"</tt> # to put a new one. def flash - @env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new) + @env[Flash::KEY] ||= (session["flash"] || Flash::FlashHash.new).tap(&:sweep) end end @@ -217,10 +217,6 @@ module ActionDispatch end def call(env) - if (session = env['rack.session']) && (flash = session['flash']) - flash.sweep - end - @app.call(env) ensure session = env['rack.session'] || {} @@ -237,7 +233,8 @@ module ActionDispatch env[KEY] = new_hash end - if session.key?('flash') && session['flash'].empty? + if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?) + session.key?('flash') && session['flash'].empty? session.delete('flash') end end |