de6539e1cc1632f6e3caed0b84105f4302ea521a
[feedcatcher.git] / vendor / rails / actionpack / test / controller / session / test_session_test.rb
1 require 'abstract_unit'
2 require 'stringio'
3
4 class ActionController::TestSessionTest < ActiveSupport::TestCase
5
6 def test_calling_delete_without_parameters_raises_deprecation_warning_and_calls_to_clear_test_session
7 assert_deprecated(/use clear instead/){ ActionController::TestSession.new.delete }
8 end
9
10 def test_calling_update_without_parameters_raises_deprecation_warning_and_calls_to_clear_test_session
11 assert_deprecated(/use replace instead/){ ActionController::TestSession.new.update }
12 end
13
14 def test_calling_close_raises_deprecation_warning
15 assert_deprecated(/sessions should no longer be closed/){ ActionController::TestSession.new.close }
16 end
17
18 def test_defaults
19 session = ActionController::TestSession.new
20 assert_equal({}, session.data)
21 assert_equal('', session.session_id)
22 end
23
24 def test_ctor_allows_setting
25 session = ActionController::TestSession.new({:one => 'one', :two => 'two'})
26 assert_equal('one', session[:one])
27 assert_equal('two', session[:two])
28 end
29
30 def test_setting_session_item_sets_item
31 session = ActionController::TestSession.new
32 session[:key] = 'value'
33 assert_equal('value', session[:key])
34 end
35
36 def test_calling_delete_removes_item
37 session = ActionController::TestSession.new
38 session[:key] = 'value'
39 assert_equal('value', session[:key])
40 session.delete(:key)
41 assert_nil(session[:key])
42 end
43
44 def test_calling_update_with_params_passes_to_attributes
45 session = ActionController::TestSession.new()
46 session.update('key' => 'value')
47 assert_equal('value', session[:key])
48 end
49
50 def test_clear_emptys_session
51 params = {:one => 'one', :two => 'two'}
52 session = ActionController::TestSession.new({:one => 'one', :two => 'two'})
53 session.clear
54 assert_nil(session[:one])
55 assert_nil(session[:two])
56 end
57
58 end