Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8782

Show
Ignore:
Timestamp:
02/02/08 05:32:44 (5 months ago)
Author:
bitsweat
Message:

TestSession supports indifferent access. Closes #7372.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r8748 r8782  
    11*SVN* 
     2 
     3* TestSession supports indifferent access.  #7372 [tamc, Arsen7, mhackett, julik, jean.helou] 
    24 
    35* Make assert_routing aware of the HTTP method used.  #8039 [mpalmer] 
  • trunk/actionpack/lib/action_controller/test_process.rb

    r8570 r8782  
    288288    def initialize(attributes = nil) 
    289289      @session_id = '' 
    290       @attributes = attributes 
     290      @attributes = attributes.nil? ? nil : attributes.stringify_keys 
    291291      @saved_attributes = nil 
    292292    end 
     
    297297 
    298298    def [](key) 
    299       data[key
     299      data[key.to_s
    300300    end 
    301301 
    302302    def []=(key, value) 
    303       data[key] = value 
     303      data[key.to_s] = value 
    304304    end 
    305305 
  • trunk/actionpack/test/controller/test_test.rb

    r8748 r8782  
    44class TestTest < Test::Unit::TestCase 
    55  class TestController < ActionController::Base 
     6    def no_op 
     7      render :text => 'dummy' 
     8    end 
     9 
    610    def set_flash 
    711      flash["test"] = ">#{flash["test"]}<" 
    812      render :text => 'ignore me' 
     13    end 
     14 
     15    def set_session 
     16      session['string'] = 'A wonder' 
     17      session[:symbol] = 'it works' 
     18      render :text => 'Success' 
    919    end 
    1020 
     
    136146  end 
    137147 
     148  def test_process_with_session 
     149    process :set_session 
     150    assert_equal 'A wonder', session['string'], "A value stored in the session should be available by string key" 
     151    assert_equal 'A wonder', session[:string], "Test session hash should allow indifferent access" 
     152    assert_equal 'it works', session['symbol'], "Test session hash should allow indifferent access" 
     153    assert_equal 'it works', session[:symbol], "Test session hash should allow indifferent access" 
     154  end 
     155 
     156  def test_process_with_session_arg 
     157    process :no_op, nil, { 'string' => 'value1', :symbol => 'value2' } 
     158    assert_equal 'value1', session['string'] 
     159    assert_equal 'value1', session[:string] 
     160    assert_equal 'value2', session['symbol'] 
     161    assert_equal 'value2', session[:symbol] 
     162  end 
     163 
    138164  def test_process_with_request_uri_with_no_params 
    139165    process :test_uri