Ticket #7372: test_session_indifferent_fixed_for_session_args.diff
| File test_session_indifferent_fixed_for_session_args.diff, 3.0 kB (added by mhackett, 2 years ago) |
|---|
-
test/controller/test_test.rb
old new 3 3 4 4 class TestTest < Test::Unit::TestCase 5 5 class TestController < ActionController::Base 6 def no_op 7 render :text => 'dummy' 8 end 9 6 10 def set_flash 7 11 flash["test"] = ">#{flash["test"]}<" 8 12 render :text => 'ignore me' 9 13 end 10 14 15 def set_session 16 session['string'] = 'A wonder' 17 session[:symbol] = 'it works' 18 render :text => 'Success' 19 end 20 11 21 def render_raw_post 12 22 raise Test::Unit::AssertionFailedError, "#raw_post is blank" if request.raw_post.blank? 13 23 render :text => request.raw_post … … 111 121 assert_equal '>value<', flash['test'] 112 122 end 113 123 124 def test_process_with_session 125 process :set_session 126 assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key" 127 assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access" 128 assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access" 129 assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access" 130 end 131 132 def test_process_with_session_arg 133 process :no_op, nil, { 'string' => 'value1', :symbol => 'value2' } 134 assert_equal 'value1', session['string'] 135 assert_equal 'value1', session[:string] 136 assert_equal 'value2', session['symbol'] 137 assert_equal 'value2', session[:symbol] 138 end 139 114 140 def test_process_with_request_uri_with_no_params 115 141 process :test_uri 116 142 assert_equal "/test_test/test/test_uri", @response.body -
lib/action_controller/test_process.rb
old new 283 283 284 284 def initialize(attributes = nil) 285 285 @session_id = '' 286 @attributes = attributes 286 @attributes = attributes.nil? ? nil : attributes.stringify_keys 287 287 @saved_attributes = nil 288 288 end 289 289 … … 292 292 end 293 293 294 294 def [](key) 295 data[key ]295 data[key.to_s] 296 296 end 297 297 298 298 def []=(key, value) 299 data[key ] = value299 data[key.to_s] = value 300 300 end 301 301 302 302 def update -
CHANGELOG
old new 1 1 *SVN* 2 2 3 * TestSession initializer also supports indifferent access when a session hash is passed to process. #7632 [tamc, Arsen7, mhackett] 4 5 * TestSession supports indifferent access so session['foo'] == session[:foo] in your tests. #7372 [julik, jean.helou] 6 3 7 * Prefer MIME constants to strings. #7707 [Dan Kubb] 4 8 5 9 * 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]