Permalink
Browse files

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.
  • Loading branch information...
1 parent c4bc360 commit f7277d99bf76e947fd404ac316eafeb993cc5bcd @michiels michiels committed Jan 28, 2013
@@ -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)

0 comments on commit f7277d9

Please sign in to comment.