diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2016-08-22 13:34:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-22 13:34:35 -0700 |
commit | debd774d632ae7e1e6c0a7d0306979159df39b63 (patch) | |
tree | 743d98e205e426284db8b823ad4cd133188c96e0 /actionpack/test/controller | |
parent | 3bfd35245278f410bb2165e859f1cfeb352e0d77 (diff) | |
download | rails-debd774d632ae7e1e6c0a7d0306979159df39b63.tar.gz rails-debd774d632ae7e1e6c0a7d0306979159df39b63.tar.bz2 rails-debd774d632ae7e1e6c0a7d0306979159df39b63.zip |
Include the content of the flash in the auto-generated etag (#26250)
Include the content of the flash in the auto-generated etag
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/flash_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb index cabbe2d608..e5f24f1a3a 100644 --- a/actionpack/test/controller/flash_test.rb +++ b/actionpack/test/controller/flash_test.rb @@ -263,6 +263,13 @@ class FlashIntegrationTest < ActionDispatch::IntegrationTest flash[:bar] = "for great justice" head :ok end + + def set_flash_optionally + flash.now.notice = params[:flash] + if stale? etag: "abe" + render inline: "maybe flash" + end + end end def test_flash @@ -310,6 +317,28 @@ class FlashIntegrationTest < ActionDispatch::IntegrationTest end end + 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 + private # Overwrite get to send SessionSecret in env hash |