aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorDamien Mathieu <42@dmathieu.com>2013-10-30 15:04:19 +0100
committerDamien Mathieu <42@dmathieu.com>2013-10-30 15:04:22 +0100
commit38f8872aa5fd8f0a1d0895e9eb41f73261acd040 (patch)
tree20c8ab179657b791808972fdee9181a341a124fa /actionpack/test
parenta02193854f995e597d008b309e6948ee97ad2122 (diff)
downloadrails-38f8872aa5fd8f0a1d0895e9eb41f73261acd040.tar.gz
rails-38f8872aa5fd8f0a1d0895e9eb41f73261acd040.tar.bz2
rails-38f8872aa5fd8f0a1d0895e9eb41f73261acd040.zip
session#fetch doesn't behave exactly like Hash#fetch.
Mention it in the changelog and add a test checking for regressions. Hash#fetch isn't adding the defaultly returned value. However, in the session, saving it is the behavior we should expect. See discussion in #12692
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/dispatch/request/session_test.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/test/dispatch/request/session_test.rb b/actionpack/test/dispatch/request/session_test.rb
index 2fed480396..a244d1364c 100644
--- a/actionpack/test/dispatch/request/session_test.rb
+++ b/actionpack/test/dispatch/request/session_test.rb
@@ -63,11 +63,15 @@ module ActionDispatch
def test_fetch
session = Session.create(store, {}, {})
- session['one'] = '1'
+ session['one'] = '1'
assert_equal '1', session.fetch(:one)
+
assert_equal '2', session.fetch(:two, '2')
+ assert_equal '2', session.fetch(:two)
+
assert_equal 'three', session.fetch(:three) {|el| el.to_s }
+ assert_equal 'three', session.fetch(:three)
assert_raise KeyError do
session.fetch(:four)