class FlashTest
Public Instance Methods
test_add_flash_type_to_subclasses()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 227 def test_add_flash_type_to_subclasses test_controller_with_flash_type_foo = Class.new(TestController) do add_flash_types :foo end subclass_controller_with_no_flash_type = Class.new(test_controller_with_flash_type_foo) assert_includes subclass_controller_with_no_flash_type._flash_types, :foo end
test_does_not_add_flash_type_to_parent_class()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 235 def test_does_not_add_flash_type_to_parent_class Class.new(TestController) do add_flash_types :bar end assert_not TestController._flash_types.include?(:bar) end
test_does_not_set_the_session_if_the_flash_is_empty()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 159 def test_does_not_set_the_session_if_the_flash_is_empty get :std_action assert_nil session["flash"] end
test_flash()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 104 def test_flash get :set_flash get :use_flash assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"] assert_equal "hello", @controller.instance_variable_get(:@flashy) get :use_flash assert_nil @controller.instance_variable_get(:@flash_copy)["that"], "On second flash" end
test_flash_after_reset_session()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 152 def test_flash_after_reset_session get :use_flash_after_reset_session assert_equal "hello", @controller.instance_variable_get(:@flashy_that) assert_equal "good-bye", @controller.instance_variable_get(:@flashy_this) assert_nil @controller.instance_variable_get(:@flashy_that_reset) end
test_flash_now()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 129 def test_flash_now get :set_flash_now assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"] assert_equal "bar", @controller.instance_variable_get(:@flash_copy)["foo"] assert_equal "hello", @controller.instance_variable_get(:@flashy) get :attempt_to_use_flash_now assert_nil @controller.instance_variable_get(:@flash_copy)["that"] assert_nil @controller.instance_variable_get(:@flash_copy)["foo"] assert_nil @controller.instance_variable_get(:@flashy) end
test_keep_and_discard_return_values()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 175 def test_keep_and_discard_return_values flash = ActionDispatch::Flash::FlashHash.new flash.update(foo: :foo_indeed, bar: :bar_indeed) assert_equal(:foo_indeed, flash.discard(:foo)) # valid key passed assert_nil flash.discard(:unknown) # non existent key passed assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.discard().to_hash) # nothing passed assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.discard(nil).to_hash) # nothing passed assert_equal(:foo_indeed, flash.keep(:foo)) # valid key passed assert_nil flash.keep(:unknown) # non existent key passed assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.keep().to_hash) # nothing passed assert_equal({ "foo" => :foo_indeed, "bar" => :bar_indeed }, flash.keep(nil).to_hash) # nothing passed end
test_keep_flash()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 115 def test_keep_flash get :set_flash get :use_flash_and_keep_it assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"] assert_equal "hello", @controller.instance_variable_get(:@flashy) get :use_flash assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"], "On second flash" get :use_flash assert_nil @controller.instance_variable_get(:@flash_copy)["that"], "On third flash" end
test_redirect_to_with_adding_flash_types()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 215 def test_redirect_to_with_adding_flash_types original_controller = @controller test_controller_with_flash_type_foo = Class.new(TestController) do add_flash_types :foo end @controller = test_controller_with_flash_type_foo.new get :redirect_with_foo_flash assert_equal "for great justice", @controller.send(:flash)[:foo] ensure @controller = original_controller end
test_redirect_to_with_alert()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 190 def test_redirect_to_with_alert get :redirect_with_alert assert_equal "Beware the nowheres!", @controller.send(:flash)[:alert] end
test_redirect_to_with_notice()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 195 def test_redirect_to_with_notice get :redirect_with_notice assert_equal "Good luck in the somewheres!", @controller.send(:flash)[:notice] end
test_redirect_to_with_other_flashes()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 210 def test_redirect_to_with_other_flashes get :redirect_with_other_flashes assert_equal "Horses!", @controller.send(:flash)[:joyride] end
test_render_with_flash_now_alert()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 200 def test_render_with_flash_now_alert get :render_with_flash_now_alert assert_equal "Beware the nowheres now!", @controller.send(:flash)[:alert] end
test_render_with_flash_now_notice()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 205 def test_render_with_flash_now_notice get :render_with_flash_now_notice assert_equal "Good luck in the somewheres now!", @controller.send(:flash)[:notice] end
test_sweep_after_halted_action_chain()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 164 def test_sweep_after_halted_action_chain get :std_action assert_nil @controller.instance_variable_get(:@flash_copy)["foo"] get :filter_halting_action assert_equal "bar", @controller.instance_variable_get(:@flash_copy)["foo"] get :std_action # follow redirection assert_equal "bar", @controller.instance_variable_get(:@flash_copy)["foo"] get :std_action assert_nil @controller.instance_variable_get(:@flash_copy)["foo"] end
test_update_flash()
click to toggle source
# File actionpack/test/controller/flash_test.rb, line 141 def test_update_flash get :set_flash get :use_flash_and_update_it assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"] assert_equal "hello again", @controller.instance_variable_get(:@flash_copy)["this"] get :use_flash assert_nil @controller.instance_variable_get(:@flash_copy)["that"], "On second flash" assert_equal "hello again", @controller.instance_variable_get(:@flash_copy)["this"], "On second flash" end