diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-02-24 00:22:04 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-02-24 00:22:04 -0300 |
commit | 22db455dbe9c26fe6d723cac0758705d9943ea4b (patch) | |
tree | f51b9bcbca80952a48501c2dbd5d72d38dd29d71 /actionpack/test/dispatch/session/cache_store_test.rb | |
parent | 40be61dfda1e04c3f306022a40370862e3a2ce39 (diff) | |
parent | 45a75a3fcc96b22954caf69be2df4e302b134d7a (diff) | |
download | rails-22db455dbe9c26fe6d723cac0758705d9943ea4b.tar.gz rails-22db455dbe9c26fe6d723cac0758705d9943ea4b.tar.bz2 rails-22db455dbe9c26fe6d723cac0758705d9943ea4b.zip |
Merge pull request #20851 from tomprats/indifferent-sessions
Give Sessions Indifferent Access
Diffstat (limited to 'actionpack/test/dispatch/session/cache_store_test.rb')
-rw-r--r-- | actionpack/test/dispatch/session/cache_store_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/session/cache_store_test.rb b/actionpack/test/dispatch/session/cache_store_test.rb index dbb996973d..b911392cf1 100644 --- a/actionpack/test/dispatch/session/cache_store_test.rb +++ b/actionpack/test/dispatch/session/cache_store_test.rb @@ -12,6 +12,11 @@ class CacheStoreTest < ActionDispatch::IntegrationTest head :ok end + def set_deep_session_value + session[:foo] = { bar: "baz" } + head :ok + end + def set_serialized_session_value session[:foo] = SessionAutoloadTest::Foo.new head :ok @@ -21,6 +26,14 @@ class CacheStoreTest < ActionDispatch::IntegrationTest 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: "#{request.session.id}" end @@ -160,6 +173,22 @@ class CacheStoreTest < ActionDispatch::IntegrationTest end end + def test_previous_session_has_indifferent_access + with_test_route_set do + get '/set_deep_session_value' + assert_response :success + assert cookies['_session_id'] + + get '/get_deep_session_value_with_symbol' + assert_response :success + assert_equal 'foo: { bar: "baz" }', response.body + + get '/get_deep_session_value_with_string' + assert_response :success + assert_equal 'foo: { "bar" => "baz" }', response.body + end + end + private def with_test_route_set with_routing do |set| |