diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2012-04-28 22:23:58 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-04-28 22:36:16 +0100 |
commit | 5c18bdca321c9152ad2770a029636b9351e91666 (patch) | |
tree | a38ad4cbec7db1d678884e436626e3eb647ebe2a /actionpack/test/controller | |
parent | e4c48fff379bef7492fc5158181395763ed843d1 (diff) | |
download | rails-5c18bdca321c9152ad2770a029636b9351e91666.tar.gz rails-5c18bdca321c9152ad2770a029636b9351e91666.tar.bz2 rails-5c18bdca321c9152ad2770a029636b9351e91666.zip |
Merge session arg with existing session instead of overwriting
This may break existing tests that are asserting the whole session contents
but should not break existing tests that are asserting individual keys - e.g:
class SomeControllerTest < ActionController::TestCase
setup do
session['user_id'] = 1
end
test "some test" do
get :some_action, nil, { 'another_var' => 2 }
# This assertion will now fail
assert_equal({ 'another_var' => 2 }, session)
# This assertion will still pass
assert_equal 2, session['another_var]
end
end
Fixes #1529.
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/test_case_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb index e8411bae0c..03b7396d5b 100644 --- a/actionpack/test/controller/test_case_test.rb +++ b/actionpack/test/controller/test_case_test.rb @@ -224,6 +224,26 @@ XML assert_equal 'value2', session[:symbol] end + def test_process_merges_session_arg + session[:foo] = 'bar' + get :no_op, nil, { :bar => 'baz' } + assert_equal 'bar', session[:foo] + assert_equal 'baz', session[:bar] + end + + def test_merged_session_arg_is_retained_across_requests + get :no_op, nil, { :foo => 'bar' } + assert_equal 'bar', session[:foo] + get :no_op + assert_equal 'bar', session[:foo] + end + + def test_process_overwrites_existing_session_arg + session[:foo] = 'bar' + get :no_op, nil, { :foo => 'baz' } + assert_equal 'baz', session[:foo] + end + def test_session_is_cleared_from_controller_after_reset_session process :set_session process :reset_the_session |