diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_process.rb | 4 | ||||
-rw-r--r-- | actionpack/test/controller/test_test.rb | 15 |
3 files changed, 20 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index afa3e12834..10105da3e2 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Allow remote_addr to be queried on TestRequest #1668 + * Fixed bug when a partial render was passing a local with the same name as the partial * Improved performance of test app req/sec with ~10% refactoring the render method #1823 [Stefan Kaes] diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index ebbb66b4ec..999a551808 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -60,6 +60,10 @@ module ActionController #:nodoc: @env['REMOTE_ADDR'] = addr end + def remote_addr + @env['REMOTE_ADDR'] + end + def request_uri @request_uri || super() end diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb index b27f3e9423..570f92e6e4 100644 --- a/actionpack/test/controller/test_test.rb +++ b/actionpack/test/controller/test_test.rb @@ -37,7 +37,11 @@ HTML end def test_only_one_param - render :text => (@params[:left] && @params[:right]) ? "EEP, Both here!" : "OK" + render :text => (params[:left] && params[:right]) ? "EEP, Both here!" : "OK" + end + + def test_remote_addr + render :text => (request.remote_addr || "not specified") end end @@ -164,4 +168,13 @@ HTML assert ActionController::Routing::Routes assert_equal routes_id, ActionController::Routing::Routes.object_id end + + def test_remote_addr + get :test_remote_addr + assert_equal "0.0.0.0", @response.body + + @request.remote_addr = "192.0.0.1" + get :test_remote_addr + assert_equal "192.0.0.1", @response.body + end end |