diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-12 16:29:21 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-02-12 16:29:21 +0000 |
commit | 93cba1207a22b0dc0e2a87769fb5b9fbc907bce7 (patch) | |
tree | 5f98fb650308eba3bf68a8c3797c04fe9b1ce9e4 | |
parent | 431edf7793c487dabdcbc7df443bff3bf30cf043 (diff) | |
download | rails-93cba1207a22b0dc0e2a87769fb5b9fbc907bce7.tar.gz rails-93cba1207a22b0dc0e2a87769fb5b9fbc907bce7.tar.bz2 rails-93cba1207a22b0dc0e2a87769fb5b9fbc907bce7.zip |
Modernize flash tests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3583 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionpack/test/controller/flash_test.rb | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index 13be68476b..53d765efe4 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -41,60 +41,45 @@ class FlashTest < Test::Unit::TestCase end def setup - initialize_request_and_response + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + @controller = TestController.new end def test_flash - @request.action = "set_flash" - response = process_request + get :set_flash - @request.action = "use_flash" - first_response = process_request - assert_equal "hello", first_response.template.assigns["flash_copy"]["that"] - assert_equal "hello", first_response.template.assigns["flashy"] + get :use_flash + assert_equal "hello", @response.template.assigns["flash_copy"]["that"] + assert_equal "hello", @response.template.assigns["flashy"] - second_response = process_request - assert_nil second_response.template.assigns["flash_copy"]["that"], "On second flash" + get :use_flash + assert_nil @response.template.assigns["flash_copy"]["that"], "On second flash" end def test_keep_flash - @request.action = "set_flash" - response = process_request + get :set_flash - @request.action = "use_flash_and_keep_it" - first_response = process_request - assert_equal "hello", first_response.template.assigns["flash_copy"]["that"] - assert_equal "hello", first_response.template.assigns["flashy"] + get :use_flash_and_keep_it + assert_equal "hello", @response.template.assigns["flash_copy"]["that"] + assert_equal "hello", @response.template.assigns["flashy"] - @request.action = "use_flash" - second_response = process_request - assert_equal "hello", second_response.template.assigns["flash_copy"]["that"], "On second flash" + get :use_flash + assert_equal "hello", @response.template.assigns["flash_copy"]["that"], "On second flash" - third_response = process_request - assert_nil third_response.template.assigns["flash_copy"]["that"], "On third flash" + get :use_flash + assert_nil @response.template.assigns["flash_copy"]["that"], "On third flash" end def test_flash_now - @request.action = "set_flash_now" - response = process_request - assert_equal "hello", response.template.assigns["flash_copy"]["that"] - assert_equal "bar" , response.template.assigns["flash_copy"]["foo"] - assert_equal "hello", response.template.assigns["flashy"] + get :set_flash_now + assert_equal "hello", @response.template.assigns["flash_copy"]["that"] + assert_equal "bar" , @response.template.assigns["flash_copy"]["foo"] + assert_equal "hello", @response.template.assigns["flashy"] - @request.action = "attempt_to_use_flash_now" - first_response = process_request - assert_nil first_response.template.assigns["flash_copy"]["that"] - assert_nil first_response.template.assigns["flash_copy"]["foo"] - assert_nil first_response.template.assigns["flashy"] + get :attempt_to_use_flash_now + assert_nil @response.template.assigns["flash_copy"]["that"] + assert_nil @response.template.assigns["flash_copy"]["foo"] + assert_nil @response.template.assigns["flashy"] end - - private - def initialize_request_and_response - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def process_request - TestController.process(@request, @response) - end -end +end
\ No newline at end of file |