Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge [6086] from trunk. References #7372.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@6087 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 454842a1f6660453a417facacc0a109e9a54d0fd 1 parent 57098ad
@jeremy jeremy authored
View
2  actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* TestSession supports indifferent access so session['foo'] == session[:foo] in your tests. #7372 [julik, jean.helou]
+
* select :multiple => true suffixes the attribute name with [] unless already suffixed. #6977 [nik.kakelin, ben, julik]
* Improve routes documentation. #7095 [zackchandler]
View
4 actionpack/lib/action_controller/test_process.rb
@@ -288,11 +288,11 @@ def data
end
def [](key)
- data[key]
+ data[key.to_s]
end
def []=(key, value)
- data[key] = value
+ data[key.to_s] = value
end
def update
View
14 actionpack/test/controller/test_test.rb
@@ -8,6 +8,12 @@ def set_flash
render :text => 'ignore me'
end
+ def set_session
+ session['string'] = 'A wonder'
+ session[:symbol] = 'it works'
+ render :text => 'Success'
+ end
+
def render_raw_post
raise Test::Unit::AssertionFailedError, "#raw_post is blank" if request.raw_post.blank?
render :text => request.raw_post
@@ -111,6 +117,14 @@ def test_process_with_flash
assert_equal '>value<', flash['test']
end
+ def test_process_with_session
+ process :set_session
+ assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key"
+ assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access"
+ assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access"
+ assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access"
+ end
+
def test_process_with_request_uri_with_no_params
process :test_uri
assert_equal "/test_test/test/test_uri", @response.body
Please sign in to comment.
Something went wrong with that request. Please try again.