diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-01-25 18:25:47 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-01-25 19:15:32 -0200 |
commit | 9df25844ba77f5ebdfe6178c78c63de53c15c45c (patch) | |
tree | 23685fb4dad58dabbd19685eb9a6b744d059e121 /actionpack | |
parent | 7d624e0e8cfa3adffd8f475e3588d83f3b367c24 (diff) | |
download | rails-9df25844ba77f5ebdfe6178c78c63de53c15c45c.tar.gz rails-9df25844ba77f5ebdfe6178c78c63de53c15c45c.tar.bz2 rails-9df25844ba77f5ebdfe6178c78c63de53c15c45c.zip |
Add keys/values methods to TestSession
Bring back the same API we have with Request::Session.
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 8 | ||||
-rw-r--r-- | actionpack/test/dispatch/session/test_session_test.rb | 16 |
2 files changed, 19 insertions, 5 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 3b241a569c..e9cf4372e4 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -251,6 +251,14 @@ module ActionController true end + def keys + @data.keys + end + + def values + @data.values + end + def destroy clear end diff --git a/actionpack/test/dispatch/session/test_session_test.rb b/actionpack/test/dispatch/session/test_session_test.rb index 904398f563..d30461a623 100644 --- a/actionpack/test/dispatch/session/test_session_test.rb +++ b/actionpack/test/dispatch/session/test_session_test.rb @@ -2,8 +2,8 @@ require 'abstract_unit' require 'stringio' class ActionController::TestSessionTest < ActiveSupport::TestCase - def test_ctor_allows_setting - session = ActionController::TestSession.new({:one => 'one', :two => 'two'}) + def test_initialize_with_values + session = ActionController::TestSession.new(one: 'one', two: 'two') assert_equal('one', session[:one]) assert_equal('two', session[:two]) end @@ -23,15 +23,21 @@ class ActionController::TestSessionTest < ActiveSupport::TestCase end def test_calling_update_with_params_passes_to_attributes - session = ActionController::TestSession.new() + session = ActionController::TestSession.new session.update('key' => 'value') assert_equal('value', session[:key]) end - def test_clear_emptys_session - session = ActionController::TestSession.new({:one => 'one', :two => 'two'}) + def test_clear_empties_session + session = ActionController::TestSession.new(one: 'one', two: 'two') session.clear assert_nil(session[:one]) assert_nil(session[:two]) end + + def test_keys_and_values + session = ActionController::TestSession.new(one: '1', two: '2') + assert_equal %w(one two), session.keys + assert_equal %w(1 2), session.values + end end |