aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/request/session_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/dispatch/request/session_test.rb')
-rw-r--r--actionpack/test/dispatch/request/session_test.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/actionpack/test/dispatch/request/session_test.rb b/actionpack/test/dispatch/request/session_test.rb
index 3f36d4f1a9..a244d1364c 100644
--- a/actionpack/test/dispatch/request/session_test.rb
+++ b/actionpack/test/dispatch/request/session_test.rb
@@ -24,7 +24,7 @@ module ActionDispatch
s['foo'] = 'bar'
s1 = Session.create(store, env, {})
- refute_equal s, s1
+ assert_not_equal s, s1
assert_equal 'bar', s1['foo']
end
@@ -61,6 +61,23 @@ module ActionDispatch
assert_equal([], s.values)
end
+ def test_fetch
+ session = Session.create(store, {}, {})
+
+ 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)
+ end
+ end
+
private
def store
Class.new {