1 require 'abstract_unit'
3 class FlashTest
< ActionController
::TestCase
4 class TestController
< ActionController
::Base
6 flash
["that"] = "hello"
7 render
:inline => "hello"
11 flash
.now
["that"] = "hello"
12 flash
.now
["foo"] ||= "bar"
13 flash
.now
["foo"] ||= "err"
14 @flashy = flash
.now
["that"]
15 @flash_copy = {}.update flash
16 render
:inline => "hello"
19 def attempt_to_use_flash_now
20 @flash_copy = {}.update flash
21 @flashy = flash
["that"]
22 render
:inline => "hello"
26 @flash_copy = {}.update flash
27 @flashy = flash
["that"]
28 render
:inline => "hello"
31 def use_flash_and_keep_it
32 @flash_copy = {}.update flash
33 @flashy = flash
["that"]
35 render
:inline => "hello"
38 def use_flash_and_update_it
39 flash
.update("this" => "hello again")
40 @flash_copy = {}.update flash
41 render
:inline => "hello"
44 def use_flash_after_reset_session
45 flash
["that"] = "hello"
46 @flashy_that = flash
["that"]
48 @flashy_that_reset = flash
["that"]
49 flash
["this"] = "good-bye"
50 @flashy_this = flash
["this"]
51 render
:inline => "hello"
55 raise unless ActionView
::MissingTemplate === e
58 # methods for test_sweep_after_halted_filter_chain
59 before_filter
:halt_and_redir, :only => "filter_halting_action"
62 @flash_copy = {}.update(flash
)
65 def filter_halting_action
66 @flash_copy = {}.update(flash
)
71 redirect_to
:action => "std_action"
72 @flash_copy = {}.update(flash
)
82 assert_equal
"hello", @response.template
.assigns
["flash_copy"]["that"]
83 assert_equal
"hello", @response.template
.assigns
["flashy"]
86 assert_nil
@response.template
.assigns
["flash_copy"]["that"], "On second flash"
92 get
:use_flash_and_keep_it
93 assert_equal
"hello", @response.template
.assigns
["flash_copy"]["that"]
94 assert_equal
"hello", @response.template
.assigns
["flashy"]
97 assert_equal
"hello", @response.template
.assigns
["flash_copy"]["that"], "On second flash"
100 assert_nil
@response.template
.assigns
["flash_copy"]["that"], "On third flash"
105 assert_equal
"hello", @response.template
.assigns
["flash_copy"]["that"]
106 assert_equal
"bar" , @response.template
.assigns
["flash_copy"]["foo"]
107 assert_equal
"hello", @response.template
.assigns
["flashy"]
109 get
:attempt_to_use_flash_now
110 assert_nil
@response.template
.assigns
["flash_copy"]["that"]
111 assert_nil
@response.template
.assigns
["flash_copy"]["foo"]
112 assert_nil
@response.template
.assigns
["flashy"]
115 def test_update_flash
117 get
:use_flash_and_update_it
118 assert_equal
"hello", @response.template
.assigns
["flash_copy"]["that"]
119 assert_equal
"hello again", @response.template
.assigns
["flash_copy"]["this"]
121 assert_nil
@response.template
.assigns
["flash_copy"]["that"], "On second flash"
122 assert_equal
"hello again", @response.template
.assigns
["flash_copy"]["this"], "On second flash"
125 def test_flash_after_reset_session
126 get
:use_flash_after_reset_session
127 assert_equal
"hello", @response.template
.assigns
["flashy_that"]
128 assert_equal
"good-bye", @response.template
.assigns
["flashy_this"]
129 assert_nil
@response.template
.assigns
["flashy_that_reset"]
132 def test_sweep_after_halted_filter_chain
134 assert_nil
@response.template
.assigns
["flash_copy"]["foo"]
135 get
:filter_halting_action
136 assert_equal
"bar", @response.template
.assigns
["flash_copy"]["foo"]
137 get
:std_action # follow redirection
138 assert_equal
"bar", @response.template
.assigns
["flash_copy"]["foo"]
140 assert_nil
@response.template
.assigns
["flash_copy"]["foo"]