diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-03-22 10:12:34 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-03-22 10:12:34 +0000 |
commit | c6d72608418989952dbb9a9b09d42c0eed74b9f1 (patch) | |
tree | 4f7a2c65121848142d02153a15a9e00a6fa0a776 /actionpack/test | |
parent | f39fe3091fe17b2f8b7836af78e033d1c939a832 (diff) | |
download | rails-c6d72608418989952dbb9a9b09d42c0eed74b9f1.tar.gz rails-c6d72608418989952dbb9a9b09d42c0eed74b9f1.tar.bz2 rails-c6d72608418989952dbb9a9b09d42c0eed74b9f1.zip |
Allow configuration of the default action cache path for #caches_action calls. [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6453 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 53db8ad843..b5846acafd 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -98,11 +98,16 @@ end class ActionCachingTestController < ActionController::Base caches_action :index + caches_action :show, :cache_path => 'http://test.host/custom/show' + caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" } def index @cache_this = Time.now.to_f.to_s render :text => @cache_this end + + alias_method :show, :index + alias_method :edit, :index def expire expire_action :controller => 'action_caching_test', :action => 'index' @@ -148,11 +153,32 @@ class ActionCacheTest < Test::Unit::TestCase get :index cached_time = content_to_cache assert_equal cached_time, @response.body + assert_cache_exists 'hostname.com/action_caching_test' reset! get :index assert_equal cached_time, @response.body end + + def test_action_cache_with_custom_cache_path + get :show + cached_time = content_to_cache + assert_equal cached_time, @response.body + assert_cache_exists 'test.host/custom/show' + reset! + + get :show + assert_equal cached_time, @response.body + end + + def test_action_cache_with_custom_cache_path_in_block + get :edit + assert_cache_exists 'test.host/edit' + reset! + + get :edit, :id => 1 + assert_cache_exists 'test.host/1;edit' + end def test_cache_expiration get :index @@ -228,4 +254,9 @@ class ActionCacheTest < Test::Unit::TestCase @controller = ActionCachingTestController.new @request.host = 'hostname.com' end + + def assert_cache_exists(path) + full_path = File.join(FILE_STORE_PATH, path + '.cache') + assert File.exist?(full_path), "#{full_path.inspect} does not exist." + end end |