class FlashIntegrationTest

Constants

Generator
SessionKey

Public Instance Methods

test_added_flash_types_method() click to toggle source
# File actionpack/test/controller/flash_test.rb, line 314
def test_added_flash_types_method
  with_test_route_set do
    get "/set_bar"
    assert_response :success
    assert_equal "for great justice", @controller.bar
  end
end
test_flash() click to toggle source
# File actionpack/test/controller/flash_test.rb, line 277
def test_flash
  with_test_route_set do
    get "/set_flash"
    assert_response :success
    assert_equal "hello", @request.flash["that"]

    get "/use_flash"
    assert_response :success
    assert_equal "flash: hello", @response.body
  end
end
test_flash_factored_into_etag() click to toggle source
# File actionpack/test/controller/flash_test.rb, line 322
def test_flash_factored_into_etag
  with_test_route_set do
    get "/set_flash_optionally"
    no_flash_etag = response.etag

    get "/set_flash_optionally", params: { flash: "hello!" }
    hello_flash_etag = response.etag

    assert_not_equal no_flash_etag, hello_flash_etag

    get "/set_flash_optionally", params: { flash: "hello!" }
    another_hello_flash_etag = response.etag

    assert_equal another_hello_flash_etag, hello_flash_etag

    get "/set_flash_optionally", params: { flash: "goodbye!" }
    goodbye_flash_etag = response.etag

    assert_not_equal another_hello_flash_etag, goodbye_flash_etag
  end
end
test_setting_flash_does_not_raise_in_following_requests() click to toggle source
# File actionpack/test/controller/flash_test.rb, line 298
def test_setting_flash_does_not_raise_in_following_requests
  with_test_route_set do
    env = { "action_dispatch.request.flash_hash" => ActionDispatch::Flash::FlashHash.new }
    get "/set_flash", env: env
    get "/set_flash", env: env
  end
end
test_setting_flash_now_does_not_raise_in_following_requests() click to toggle source
# File actionpack/test/controller/flash_test.rb, line 306
def test_setting_flash_now_does_not_raise_in_following_requests
  with_test_route_set do
    env = { "action_dispatch.request.flash_hash" => ActionDispatch::Flash::FlashHash.new }
    get "/set_flash_now", env: env
    get "/set_flash_now", env: env
  end
end

Private Instance Methods

get(path, *args) click to toggle source

Overwrite get to send SessionSecret in env hash

Calls superclass method TestHelpers::Rack#get
# File actionpack/test/controller/flash_test.rb, line 347
def get(path, *args)
  args[0] ||= {}
  args[0][:env] ||= {}
  args[0][:env]["action_dispatch.key_generator"] ||= Generator
  super(path, *args)
end
with_test_route_set() { || ... } click to toggle source
# File actionpack/test/controller/flash_test.rb, line 354
def with_test_route_set
  with_routing do |set|
    set.draw do
      ActiveSupport::Deprecation.silence do
        get ":action", to: FlashIntegrationTest::TestController
      end
    end

    @app = self.class.build_app(set) do |middleware|
      middleware.use ActionDispatch::Session::CookieStore, key: SessionKey
      middleware.use ActionDispatch::Flash
      middleware.delete ActionDispatch::ShowExceptions
    end

    yield
  end
end