diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-01-28 13:20:52 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-01-28 13:20:52 -0800 |
commit | 764397f17d4140232c1aa62bc593b3e5f25485e7 (patch) | |
tree | 95255bee92b4a5a8129bfd8380c88a984bcc38dc | |
parent | 8fff05ad3212e4302f186ca154a120f00d1b6abd (diff) | |
parent | 489138802c3d5f2cdafc8cea22eac0da446099cc (diff) | |
download | rails-764397f17d4140232c1aa62bc593b3e5f25485e7.tar.gz rails-764397f17d4140232c1aa62bc593b3e5f25485e7.tar.bz2 rails-764397f17d4140232c1aa62bc593b3e5f25485e7.zip |
Merge pull request #9098 from firmhouse/add-head-requests
Make current_url? work with HEAD requests and remove caching_allowed? since it doesn't do anything
-rw-r--r-- | actionpack/CHANGELOG.md | 5 | ||||
-rw-r--r-- | actionpack/lib/action_controller/caching.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/url_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 6 |
4 files changed, 12 insertions, 5 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index a35caf6a94..745489a270 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,5 +1,10 @@ ## Rails 4.0.0 (unreleased) ## +* Fix that CSRF protection and current_url? helper work with HEAD requests + now ActionDispatch::Head has been removed in favor of Rack::Head. + + *Michiel Sikkes* + * Change asset_path to not include `SCRIPT_NAME` when it's used from a mounted engine (fixes #8119). diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index cf2cda039d..ea33d975ef 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -82,10 +82,6 @@ module ActionController end end - def caching_allowed? - request.get? && response.status == 200 - end - def view_cache_dependencies self.class._view_cache_dependencies.map { |dep| instance_exec(&dep) }.compact end diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index bade121d44..5e20b557d8 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -514,7 +514,7 @@ module ActionView "in a #request method" end - return false unless request.get? + return false unless request.get? || request.head? url_string = url_for(options) diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index ba65349b6a..5d87c96605 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -437,6 +437,12 @@ class UrlHelperTest < ActiveSupport::TestCase 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) |