public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
Merge r8782 from trunk: TestSession supports indifferent access. 
References #7372.

git-svn-id: 
http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@8784 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jeremy (author)
Fri Feb 01 21:37:22 -0800 2008
commit  f756bfbe89da504729a1e59d1cbfc4044257057d
tree    febf995f04bd445bd5fb1a2fa6b697222dec7ce5
parent  e85fcc0518605ca1602a1353bbb616ad2a34e351
...
 
 
 
 
 
1
2
3
4
5
 
6
7
8
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
0
@@ -1,8 +1,14 @@
0
+*SVN*
0
+
0
+* TestSession supports indifferent access. #7372 [tamc, Arsen7, mhackett, julik, jean.helou]
0
+
0
+
0
 *1.13.6* (November 24th, 2007)
0
 
0
 * Correct Broken Fix for session_fixation attacks
0
 
0
 * Ensure that cookies handle array values correctly. Closes #9937 [queso]
0
+
0
 
0
 *1.13.5* (October 12th, 2007)
0
 
...
282
283
284
285
 
286
287
288
289
...
291
292
293
294
 
295
296
297
298
 
299
300
301
...
282
283
284
 
285
286
287
288
289
...
291
292
293
 
294
295
296
297
 
298
299
300
301
0
@@ -282,7 +282,7 @@
0
 
0
     def initialize(attributes = nil)
0
       @session_id = ''
0
- @attributes = attributess
0
+ @attributes = attributes.nil? ? nil : attributes.stringify_keys
0
       @saved_attributes = nil
0
     end
0
 
0
0
@@ -291,11 +291,11 @@
0
     end
0
 
0
     def [](key)
0
- data[key]
0
+ data[key.to_s]
0
     end
0
 
0
     def []=(key, value)
0
- data[key] = value
0
+ data[key.to_s] = value
0
     end
0
 
0
     def update
...
3
4
5
 
 
 
 
6
7
8
9
10
 
 
 
 
 
 
11
12
13
...
109
110
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
113
114
...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
0
@@ -3,11 +3,21 @@
0
 
0
 class TestTest < Test::Unit::TestCase
0
   class TestController < ActionController::Base
0
+ def no_op
0
+ render :text => 'dummy'
0
+ end
0
+
0
     def set_flash
0
       flash["test"] = ">#{flash["test"]}<"
0
       render :text => 'ignore me'
0
     end
0
 
0
+ def set_session
0
+ session['string'] = 'A wonder'
0
+ session[:symbol] = 'it works'
0
+ render :text => 'Success'
0
+ end
0
+
0
     def render_raw_post
0
       raise Test::Unit::AssertionFailedError, "#raw_post is blank" if request.raw_post.blank?
0
       render :text => request.raw_post
0
@@ -109,6 +119,22 @@
0
   def test_process_with_flash
0
     process :set_flash, nil, nil, { "test" => "value" }
0
     assert_equal '>value<', flash['test']
0
+ end
0
+
0
+ def test_process_with_session
0
+ process :set_session
0
+ assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key"
0
+ assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access"
0
+ assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access"
0
+ assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access"
0
+ end
0
+
0
+ def test_process_with_session_arg
0
+ process :no_op, nil, { 'string' => 'value1', :symbol => 'value2' }
0
+ assert_equal 'value1', session['string']
0
+ assert_equal 'value1', session[:string]
0
+ assert_equal 'value2', session['symbol']
0
+ assert_equal 'value2', session[:symbol]
0
   end
0
 
0
   def test_process_with_request_uri_with_no_params

Comments

    No one has commented yet.