diff options
author | Tom Prats <tprats108@gmail.com> | 2016-01-30 19:30:32 -0500 |
---|---|---|
committer | Tom Prats <tprats108@gmail.com> | 2016-01-30 19:30:32 -0500 |
commit | 45a75a3fcc96b22954caf69be2df4e302b134d7a (patch) | |
tree | 1f4ef44ceb84e9aebb264c85c976cae0db661d09 /actionpack/test/dispatch/session/cookie_store_test.rb | |
parent | 82dc8266dddc199789f3f1e9a9f21975e1c8ee87 (diff) | |
download | rails-45a75a3fcc96b22954caf69be2df4e302b134d7a.tar.gz rails-45a75a3fcc96b22954caf69be2df4e302b134d7a.tar.bz2 rails-45a75a3fcc96b22954caf69be2df4e302b134d7a.zip |
Update Session to utilize indiffernt access
Diffstat (limited to 'actionpack/test/dispatch/session/cookie_store_test.rb')
-rw-r--r-- | actionpack/test/dispatch/session/cookie_store_test.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb index f07e215e3a..71402b021a 100644 --- a/actionpack/test/dispatch/session/cookie_store_test.rb +++ b/actionpack/test/dispatch/session/cookie_store_test.rb @@ -24,10 +24,23 @@ class CookieStoreTest < ActionDispatch::IntegrationTest render plain: Rack::Utils.escape(Verifier.generate(session.to_hash)) end + def set_deep_session_value + session[:foo] = { bar: "baz" } + render plain: Rack::Utils.escape(Verifier.generate(session.to_hash)) + end + def get_session_value render plain: "foo: #{session[:foo].inspect}" end + def get_deep_session_value_with_symbol + render plain: "foo: { bar: #{session[:foo][:bar].inspect} }" + end + + def get_deep_session_value_with_string + render plain: "foo: { \"bar\" => #{session[:foo]["bar"].inspect} }" + end + def get_session_id render plain: "id: #{request.session.id}" end @@ -81,6 +94,15 @@ class CookieStoreTest < ActionDispatch::IntegrationTest end end + def test_session_indifferent_access + with_test_route_set do + cookies[SessionKey] = SignedBar + get '/get_session_value' + assert_response :success + assert_equal 'foo: "bar"', response.body + end + end + def test_getting_session_id with_test_route_set do cookies[SessionKey] = SignedBar @@ -332,6 +354,18 @@ class CookieStoreTest < ActionDispatch::IntegrationTest end end + def test_previous_session_has_indifferent_access + with_test_route_set do + get '/set_deep_session_value' + + get '/get_deep_session_value_with_symbol' + assert_equal 'foo: { bar: "baz" }', response.body + + get '/get_deep_session_value_with_string' + assert_equal 'foo: { "bar" => "baz" }', response.body + end + end + private # Overwrite get to send SessionSecret in env hash |