From 3004cc817794527fa44c727eea87e20b65c686ce Mon Sep 17 00:00:00 2001 From: Matthew Gerrior Date: Fri, 27 Jun 2014 17:27:41 -0400 Subject: Adds missing argument handling for ActionController::TestSession to allow testing controllers that use session#fetch with a default value. --- actionpack/test/dispatch/session/test_session_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'actionpack/test/dispatch/session') diff --git a/actionpack/test/dispatch/session/test_session_test.rb b/actionpack/test/dispatch/session/test_session_test.rb index d30461a623..59c030176b 100644 --- a/actionpack/test/dispatch/session/test_session_test.rb +++ b/actionpack/test/dispatch/session/test_session_test.rb @@ -40,4 +40,14 @@ class ActionController::TestSessionTest < ActiveSupport::TestCase assert_equal %w(one two), session.keys assert_equal %w(1 2), session.values end + + def test_fetch_returns_default + session = ActionController::TestSession.new(one: '1') + assert_equal('2', session.fetch(:two, '2')) + end + + def test_fetch_returns_block_value + session = ActionController::TestSession.new(one: '1') + assert_equal(2, session.fetch('2') { |key| key.to_i }) + end end -- cgit v1.2.3