From 8639c10a40604cee2f3d412470c2960712fdc809 Mon Sep 17 00:00:00 2001
From: Krekoten' Marjan <krekoten@gmail.com>
Date: Wed, 22 Sep 2010 23:17:49 +0300
Subject: Fix logging when cache key contains % sign [#5570 state:resolved]
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: José Valim <jose.valim@gmail.com>
---
 actionpack/lib/action_controller/log_subscriber.rb |  2 +-
 actionpack/test/controller/log_subscriber_test.rb  | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

(limited to 'actionpack')

diff --git a/actionpack/lib/action_controller/log_subscriber.rb b/actionpack/lib/action_controller/log_subscriber.rb
index ece270b3ce..3b19310a69 100644
--- a/actionpack/lib/action_controller/log_subscriber.rb
+++ b/actionpack/lib/action_controller/log_subscriber.rb
@@ -42,7 +42,7 @@ module ActionController
         def #{method}(event)
           key_or_path = event.payload[:key] || event.payload[:path]
           human_name  = #{method.to_s.humanize.inspect}
-          info("\#{human_name} \#{key_or_path} (%.1fms)" % event.duration)
+          info("\#{human_name} \#{key_or_path} \#{"(%.1fms)" % event.duration}")
         end
       METHOD
     end
diff --git a/actionpack/test/controller/log_subscriber_test.rb b/actionpack/test/controller/log_subscriber_test.rb
index 414eec4f9d..7f7246d15c 100644
--- a/actionpack/test/controller/log_subscriber_test.rb
+++ b/actionpack/test/controller/log_subscriber_test.rb
@@ -23,6 +23,10 @@ module Another
     def with_fragment_cache
       render :inline => "<%= cache('foo'){ 'bar' } %>"
     end
+    
+    def with_fragment_cache_and_percent_in_key
+      render :inline => "<%= cache('foo%bar'){ 'Contains % sign in key' } %>"
+    end
 
     def with_page_cache
       cache_page("Super soaker", "/index.html")
@@ -140,6 +144,18 @@ class ACLogSubscriberTest < ActionController::TestCase
   ensure
     @controller.config.perform_caching = true
   end
+  
+  def test_with_fragment_cache_and_percent_in_key
+    @controller.config.perform_caching = true
+    get :with_fragment_cache_and_percent_in_key
+    wait
+
+    assert_equal 4, logs.size
+    assert_match /Exist fragment\? views\/foo%bar/, logs[1]
+    assert_match /Write fragment views\/foo%bar/, logs[2]
+  ensure
+    @controller.config.perform_caching = true
+  end
 
   def test_with_page_cache
     @controller.config.perform_caching = true
-- 
cgit v1.2.3