提交 020ed6fa 编写于 作者: J Jamis Buck

Allow remote_addr to be queried on TestRequest #1668


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1960 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 b4c34f7b
*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]
......
......@@ -60,6 +60,10 @@ def remote_addr=(addr)
@env['REMOTE_ADDR'] = addr
end
def remote_addr
@env['REMOTE_ADDR']
end
def request_uri
@request_uri || super()
end
......
......@@ -37,7 +37,11 @@ def test_html_output
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 @@ def test_with_routing_places_routes_back
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册