From 69339e54d3464c6e4193ce744f975fd52b348449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 1 Aug 2013 10:43:45 -0300 Subject: Fix `current_page?` when the URL contains escaped characters In some cases webservers like nginx send the escaped characters lowercased to the Rails application. The current_page? helper was comparing the escaped strings that are different since Ruby escapes the URL using uppercased characters. --- actionview/test/template/url_helper_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'actionview/test/template') diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 851ea8796f..9d9bd01de0 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -17,6 +17,7 @@ class UrlHelperTest < ActiveSupport::TestCase get "/" => "foo#bar" get "/other" => "foo#other" get "/article/:id" => "foo#article", :as => :article + get "/category/:category" => "foo#category" end include ActionView::Helpers::UrlHelper @@ -401,6 +402,18 @@ class UrlHelperTest < ActiveSupport::TestCase assert !current_page?('/events') end + def test_current_page_with_escaped_params + @request = request_for_url("/category/administra%c3%a7%c3%a3o") + + assert current_page?(controller: 'foo', action: 'category', category: 'administração') + end + + def test_current_page_with_double_escaped_params + @request = request_for_url("/category/administra%c3%a7%c3%a3o?callback_url=http%3a%2f%2fexample.com%2ffoo") + + assert current_page?(controller: 'foo', action: 'category', category: 'administração', callback_url: 'http://example.com/foo') + end + def test_link_unless_current @request = request_for_url("/") -- cgit v1.2.3