Skip to content

Commit

Permalink
Fix logging when cache key contains % sign [#5570 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
krekoten authored and josevalim committed Sep 25, 2010
1 parent da94d0e commit 8639c10
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/log_subscriber.rb
Expand Up @@ -42,7 +42,7 @@ def send_data(event)
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
Expand Down
16 changes: 16 additions & 0 deletions actionpack/test/controller/log_subscriber_test.rb
Expand Up @@ -23,6 +23,10 @@ def file_sender
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")
Expand Down Expand Up @@ -140,6 +144,18 @@ def test_with_fragment_cache
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
Expand Down

0 comments on commit 8639c10

Please sign in to comment.