diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2014-02-08 23:56:40 -0500 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-02-11 01:54:17 -0800 |
commit | a6ce984b49519de7701aa13d04300c9d03cf8f72 (patch) | |
tree | ee5225bba4855712c77be2746fe3a44f64af417e /actionpack/test | |
parent | ba6861d032013416034cdb20012962b97460795f (diff) | |
download | rails-a6ce984b49519de7701aa13d04300c9d03cf8f72.tar.gz rails-a6ce984b49519de7701aa13d04300c9d03cf8f72.tar.bz2 rails-a6ce984b49519de7701aa13d04300c9d03cf8f72.zip |
Convert FlashHash in a Hash with indifferent access
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/flash_hash_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/test/controller/flash_hash_test.rb b/actionpack/test/controller/flash_hash_test.rb index 5490d9394b..50b36a0567 100644 --- a/actionpack/test/controller/flash_hash_test.rb +++ b/actionpack/test/controller/flash_hash_test.rb @@ -67,6 +67,16 @@ module ActionDispatch assert_equal({'flashes' => {'message' => 'Hello'}, 'discard' => %w[message]}, hash.to_session_value) end + def test_from_session_value_on_json_serializer + decrypted_data = "{ \"session_id\":\"d98bdf6d129618fc2548c354c161cfb5\", \"flash\":{\"discard\":[], \"flashes\":{\"message\":\"hey you\"}} }" + session = ActionDispatch::Cookies::JsonSerializer.load(decrypted_data) + hash = Flash::FlashHash.from_session_value(session['flash']) + + assert_equal({'discard' => %w[message], 'flashes' => { 'message' => 'hey you'}}, hash.to_session_value) + assert_equal "hey you", hash[:message] + assert_equal "hey you", hash["message"] + end + def test_empty? assert @hash.empty? @hash['zomg'] = 'bears' |