From ead93c5be5b0f1945b7d0302f1aae4685ee3f2fb Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Fri, 15 Jan 2010 14:44:27 -0600 Subject: Move Flash into middleware --- actionpack/test/abstract_unit.rb | 2 ++ actionpack/test/controller/flash_test.rb | 42 ++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index f26542b31e..10913c0fdb 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -87,10 +87,12 @@ end class ActionController::IntegrationTest < ActiveSupport::TestCase def self.build_app(routes = nil) + ActionDispatch::Flash ActionDispatch::MiddlewareStack.new { |middleware| middleware.use "ActionDispatch::ShowExceptions" middleware.use "ActionDispatch::Callbacks" middleware.use "ActionDispatch::ParamsParser" + middleware.use "ActionDispatch::Flash" middleware.use "ActionDispatch::Head" }.build(routes || ActionController::Routing::Routes) end diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index a9b60386f1..85a2e7f44b 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -159,7 +159,7 @@ class FlashTest < ActionController::TestCase end def test_keep_and_discard_return_values - flash = ActionController::Flash::FlashHash.new + flash = ActionDispatch::Flash::FlashHash.new flash.update(:foo => :foo_indeed, :bar => :bar_indeed) assert_equal(:foo_indeed, flash.discard(:foo)) # valid key passed @@ -187,4 +187,42 @@ class FlashTest < ActionController::TestCase get :redirect_with_other_flashes assert_equal "Horses!", @controller.send(:flash)[:joyride] end -end \ No newline at end of file +end + +class FlashIntegrationTest < ActionController::IntegrationTest + SessionKey = '_myapp_session' + SessionSecret = 'b3c631c314c0bbca50c1b2843150fe33' + + class TestController < ActionController::Base + def set_flash + flash["that"] = "hello" + head :ok + end + + def use_flash + render :inline => "flash: #{flash["that"]}" + end + end + + def test_flash + with_test_route_set do + get '/set_flash' + assert_response :success + assert_equal "hello", @request.flash["that"] + + get '/use_flash' + assert_response :success + assert_equal "flash: hello", @response.body + end + end + + private + def with_test_route_set + with_routing do |set| + set.draw do |map| + match ':action', :to => ActionDispatch::Session::CookieStore.new(TestController, :key => SessionKey, :secret => SessionSecret) + end + yield + end + end +end -- cgit v1.2.3