diff options
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/action_pack_assertions_test.rb | 3 | ||||
-rw-r--r-- | actionpack/test/controller/flash_test.rb | 35 |
2 files changed, 31 insertions, 7 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 48d7ed2f3f..4eadbf4e34 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -179,7 +179,6 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase # test the flash-based assertions with no flash at all def test_flash_assertions_negative process :nothing - assert_flash_not_exists assert_flash_empty assert_flash_has_no 'hello' assert_flash_has_no 'qwerty' @@ -230,7 +229,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase # check the empty flashing def test_flash_me_naked process :flash_me_naked - assert @response.has_flash? + assert !@response.has_flash? assert !@response.has_flash_with_contents? end diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index 033477fe39..3a6e828bc8 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -7,12 +7,26 @@ class FlashTest < Test::Unit::TestCase render_text "hello" end + def set_flash_now + flash.now["that"] = "hello" + @flash_copy = {}.update flash + render_text "hello" + end + + def attempt_to_use_flash_now + @flash_copy = {}.update flash + @flashy = flash["that"] + render_text "hello" + end + def use_flash + @flash_copy = {}.update flash @flashy = flash["that"] render_text "hello" end def use_flash_and_keep_it + @flash_copy = {}.update flash @flashy = flash["that"] keep_flash render_text "hello" @@ -33,11 +47,11 @@ class FlashTest < Test::Unit::TestCase @request.action = "use_flash" first_response = process_request - assert_equal "hello", first_response.template.assigns["flash"]["that"] + assert_equal "hello", first_response.template.assigns["flash_copy"]["that"] assert_equal "hello", first_response.template.assigns["flashy"] second_response = process_request - assert_nil second_response.template.assigns["flash"]["that"], "On second flash" + assert_nil second_response.template.assigns["flash_copy"]["that"], "On second flash" end def test_keep_flash @@ -46,17 +60,28 @@ class FlashTest < Test::Unit::TestCase @request.action = "use_flash_and_keep_it" first_response = process_request - assert_equal "hello", first_response.template.assigns["flash"]["that"] + assert_equal "hello", first_response.template.assigns["flash_copy"]["that"] assert_equal "hello", first_response.template.assigns["flashy"] @request.action = "use_flash" second_response = process_request - assert_equal "hello", second_response.template.assigns["flash"]["that"], "On second flash" + assert_equal "hello", second_response.template.assigns["flash_copy"]["that"], "On second flash" third_response = process_request - assert_nil third_response.template.assigns["flash"]["that"], "On third flash" + assert_nil third_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"] + + @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["flashy"] + end + private def initialize_request_and_response @request = ActionController::TestRequest.new |