Namespace
Methods
T
Instance Public methods
test_add_flash_type_to_subclasses()
# File actionpack/test/controller/flash_test.rb, line 225
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 subclass_controller_with_no_flash_type._flash_types.include?(:foo)
end
test_does_not_add_flash_type_to_parent_class()
# File actionpack/test/controller/flash_test.rb, line 233
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()
# File actionpack/test/controller/flash_test.rb, line 157
def test_does_not_set_the_session_if_the_flash_is_empty
  get :std_action
  assert_nil session["flash"]
end
test_flash()
# File actionpack/test/controller/flash_test.rb, line 102
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()
# File actionpack/test/controller/flash_test.rb, line 150
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()
# File actionpack/test/controller/flash_test.rb, line 127
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()
# File actionpack/test/controller/flash_test.rb, line 173
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()
# File actionpack/test/controller/flash_test.rb, line 113
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()
# File actionpack/test/controller/flash_test.rb, line 213
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()
# File actionpack/test/controller/flash_test.rb, line 188
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()
# File actionpack/test/controller/flash_test.rb, line 193
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()
# File actionpack/test/controller/flash_test.rb, line 208
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()
# File actionpack/test/controller/flash_test.rb, line 198
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()
# File actionpack/test/controller/flash_test.rb, line 203
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()
# File actionpack/test/controller/flash_test.rb, line 162
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()
# File actionpack/test/controller/flash_test.rb, line 139
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