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

Changeset 8783

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

Merge r8782 from trunk: TestSession supports indifferent access. References #7372.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2-0-stable/actionpack/CHANGELOG

    r8618 r8783  
    11*SVN* 
     2 
     3* TestSession supports indifferent access.  #7372 [tamc, Arsen7, mhackett, julik, jean.helou] 
    24 
    35* UrlWriter respects relative_url_root.  #10748 [Cheah Chu Yeow] 
  • branches/2-0-stable/actionpack/lib/action_controller/test_process.rb

    r8318 r8783  
    287287    def initialize(attributes = nil) 
    288288      @session_id = '' 
    289       @attributes = attributes 
     289      @attributes = attributes.nil? ? nil : attributes.stringify_keys 
    290290      @saved_attributes = nil 
    291291    end 
     
    296296 
    297297    def [](key) 
    298       data[key
     298      data[key.to_s
    299299    end 
    300300 
    301301    def []=(key, value) 
    302       data[key] = value 
     302      data[key.to_s] = value 
    303303    end 
    304304 
  • branches/2-0-stable/actionpack/test/controller/test_test.rb

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