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

Changeset 1960

Show
Ignore:
Timestamp:
07/31/05 10:31:47 (3 years ago)
Author:
minam
Message:

Allow remote_addr to be queried on TestRequest #1668

Files:

Legend:

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

    r1942 r1960  
    11*SVN* 
     2 
     3* Allow remote_addr to be queried on TestRequest #1668 
    24 
    35* Fixed bug when a partial render was passing a local with the same name as the partial 
  • trunk/actionpack/lib/action_controller/test_process.rb

    r1905 r1960  
    5959    def remote_addr=(addr) 
    6060      @env['REMOTE_ADDR'] = addr 
     61    end 
     62 
     63    def remote_addr 
     64      @env['REMOTE_ADDR'] 
    6165    end 
    6266 
  • trunk/actionpack/test/controller/test_test.rb

    r1874 r1960  
    3838     
    3939    def test_only_one_param 
    40       render :text => (@params[:left] && @params[:right]) ? "EEP, Both here!" : "OK" 
     40      render :text => (params[:left] && params[:right]) ? "EEP, Both here!" : "OK" 
     41    end 
     42 
     43    def test_remote_addr 
     44      render :text => (request.remote_addr || "not specified") 
    4145    end 
    4246  end 
     
    165169    assert_equal routes_id, ActionController::Routing::Routes.object_id 
    166170  end 
     171 
     172  def test_remote_addr 
     173    get :test_remote_addr 
     174    assert_equal "0.0.0.0", @response.body 
     175 
     176    @request.remote_addr = "192.0.0.1" 
     177    get :test_remote_addr 
     178    assert_equal "192.0.0.1", @response.body 
     179  end 
    167180end