From 10cab35d3b9e87e4b182162f7783c220cf2a937f Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Sat, 5 Feb 2011 15:52:16 -0800 Subject: Allow page_cache_directory to be set as a Pathname For example, page_cache_directory = Rails.root.join("public/cache") Signed-off-by: Santiago Pastorino --- actionpack/lib/action_controller/caching/pages.rb | 2 +- actionpack/test/controller/caching_test.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/caching/pages.rb b/actionpack/lib/action_controller/caching/pages.rb index 3e57d2c236..8c583c7ce0 100644 --- a/actionpack/lib/action_controller/caching/pages.rb +++ b/actionpack/lib/action_controller/caching/pages.rb @@ -106,7 +106,7 @@ module ActionController #:nodoc: end def page_cache_path(path, extension = nil) - page_cache_directory + page_cache_file(path, extension) + page_cache_directory.to_s + page_cache_file(path, extension) end def instrument_page_cache(name, path) diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index af02c7f9fa..cc393d3ef4 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -156,6 +156,17 @@ class PageCachingTest < ActionController::TestCase assert_page_not_cached :ok end + def test_page_caching_directory_set_as_pathname + begin + ActionController::Base.page_cache_directory = Pathname.new(FILE_STORE_PATH) + get :ok + assert_response :ok + assert_page_cached :ok + ensure + ActionController::Base.page_cache_directory = FILE_STORE_PATH + end + end + private def assert_page_cached(action, message = "#{action} should have been cached") assert page_cached?(action), message -- cgit v1.2.3