提交 f7277d99 编写于 作者: M Michiel Sikkes

Make current_url? work with a HEAD method

ActionDispatch::Head was removed in favor of Rack::Head. But Rack::Head
does not convert GET requests to HEAD requests so we need to do
checking for HEAD requests ourselves.
上级 c4bc360e
......@@ -514,7 +514,7 @@ def current_page?(options)
"in a #request method"
end
return false unless request.get?
return false unless request.get? || request.head?
url_string = url_for(options)
......
......@@ -437,6 +437,12 @@ def request_for_url(url, opts = {})
ActionDispatch::Request.new(env)
end
def test_current_page_with_http_head_method
@request = request_for_url("/", :method => :head)
assert current_page?(url_hash)
assert current_page?("http://www.example.com/")
end
def test_current_page_with_simple_url
@request = request_for_url("/")
assert current_page?(url_hash)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册