Navigation Menu

Skip to content

Commit

Permalink
Merge r8782 from trunk: TestSession supports indifferent access. Refe…
Browse files Browse the repository at this point in the history
…rences rails#7372.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@8784 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Feb 2, 2008
1 parent e85fcc0 commit f756bfb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions actionpack/CHANGELOG
@@ -1,9 +1,15 @@
*SVN*

* TestSession supports indifferent access. #7372 [tamc, Arsen7, mhackett, julik, jean.helou]


*1.13.6* (November 24th, 2007)

* Correct Broken Fix for session_fixation attacks

* Ensure that cookies handle array values correctly. Closes #9937 [queso]


*1.13.5* (October 12th, 2007)

* Backport: allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan, Diego Algorta Casamayou]
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/test_process.rb
Expand Up @@ -282,7 +282,7 @@ class TestSession #:nodoc:

def initialize(attributes = nil)
@session_id = ''
@attributes = attributes
@attributes = attributes.nil? ? nil : attributes.stringify_keys
@saved_attributes = nil
end

Expand All @@ -291,11 +291,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
Expand Down
26 changes: 26 additions & 0 deletions actionpack/test/controller/test_test.rb
Expand Up @@ -3,11 +3,21 @@

class TestTest < Test::Unit::TestCase
class TestController < ActionController::Base
def no_op
render :text => 'dummy'
end

def set_flash
flash["test"] = ">#{flash["test"]}<"
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
Expand Down Expand Up @@ -111,6 +121,22 @@ 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_session_arg
process :no_op, nil, { 'string' => 'value1', :symbol => 'value2' }
assert_equal 'value1', session['string']
assert_equal 'value1', session[:string]
assert_equal 'value2', session['symbol']
assert_equal 'value2', session[:symbol]
end

def test_process_with_request_uri_with_no_params
process :test_uri
assert_equal "/test_test/test/test_uri", @response.body
Expand Down

0 comments on commit f756bfb

Please sign in to comment.