aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/flash_hash_test.rb
diff options
context:
space:
mode:
authorSamuel Cochran <sj26@sj26.com>2015-01-29 23:18:55 +1100
committerSamuel Cochran <sj26@sj26.com>2015-01-29 23:18:55 +1100
commitf7adb34999eb4df7916102b60f5aa3f0ddc8210c (patch)
tree94019b9fcc8c227e41efa19226c8f8632c0f51f7 /actionpack/test/controller/flash_hash_test.rb
parent3a102d052803f7f066e648454297301310d69906 (diff)
downloadrails-f7adb34999eb4df7916102b60f5aa3f0ddc8210c.tar.gz
rails-f7adb34999eb4df7916102b60f5aa3f0ddc8210c.tar.bz2
rails-f7adb34999eb4df7916102b60f5aa3f0ddc8210c.zip
Discard from flash before persisting in session
Diffstat (limited to 'actionpack/test/controller/flash_hash_test.rb')
-rw-r--r--actionpack/test/controller/flash_hash_test.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/actionpack/test/controller/flash_hash_test.rb b/actionpack/test/controller/flash_hash_test.rb
index d979b561f2..93ed5a037e 100644
--- a/actionpack/test/controller/flash_hash_test.rb
+++ b/actionpack/test/controller/flash_hash_test.rb
@@ -57,13 +57,13 @@ module ActionDispatch
def test_to_session_value
@hash['foo'] = 'bar'
- assert_equal({'flashes' => {'foo' => 'bar'}, 'discard' => []}, @hash.to_session_value)
-
- @hash.discard('foo')
- assert_equal({'flashes' => {'foo' => 'bar'}, 'discard' => %w[foo]}, @hash.to_session_value)
+ assert_equal({'flashes' => {'foo' => 'bar'}}, @hash.to_session_value)
@hash.now['qux'] = 1
- assert_equal({'flashes' => {'foo' => 'bar', 'qux' => 1}, 'discard' => %w[foo qux]}, @hash.to_session_value)
+ assert_equal({'flashes' => {'foo' => 'bar'}}, @hash.to_session_value)
+
+ @hash.discard('foo')
+ assert_equal(nil, @hash.to_session_value)
@hash.sweep
assert_equal(nil, @hash.to_session_value)
@@ -73,7 +73,8 @@ module ActionDispatch
rails_3_2_cookie = 'BAh7B0kiD3Nlc3Npb25faWQGOgZFRkkiJWY4ZTFiODE1MmJhNzYwOWMyOGJiYjE3ZWM5MjYzYmE3BjsAVEkiCmZsYXNoBjsARm86JUFjdGlvbkRpc3BhdGNoOjpGbGFzaDo6Rmxhc2hIYXNoCToKQHVzZWRvOghTZXQGOgpAaGFzaHsAOgxAY2xvc2VkRjoNQGZsYXNoZXN7BkkiDG1lc3NhZ2UGOwBGSSIKSGVsbG8GOwBGOglAbm93MA=='
session = Marshal.load(Base64.decode64(rails_3_2_cookie))
hash = Flash::FlashHash.from_session_value(session['flash'])
- assert_equal({'flashes' => {'message' => 'Hello'}, 'discard' => %w[message]}, hash.to_session_value)
+ assert_equal({'message' => 'Hello'}, hash.to_hash)
+ assert_equal(nil, hash.to_session_value)
end
def test_from_session_value_on_json_serializer
@@ -81,7 +82,8 @@ module ActionDispatch
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({'message' => 'hey you'}, hash.to_hash)
+ assert_equal(nil, hash.to_session_value)
assert_equal "hey you", hash[:message]
assert_equal "hey you", hash["message"]
end