Changeset 6868
- Timestamp:
- 05/27/07 16:38:02 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/caching.rb (modified) (2 diffs)
- trunk/actionpack/test/abstract_unit.rb (modified) (1 diff)
- trunk/actionpack/test/controller/caching_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6867 r6868 1 1 *SVN* 2 3 * Added custom path cache_page/expire_page parameters in addition to the options hashes [DHH]. Example: 4 5 def index 6 caches_page(response.body, "/index.html") 7 end 2 8 3 9 * Action Caching speedup. #8231 [skaes] trunk/actionpack/lib/action_controller/caching.rb
r6867 r6868 119 119 def expire_page(options = {}) 120 120 return unless perform_caching 121 if options[:action].is_a?(Array) 122 options[:action].dup.each do |action| 123 self.class.expire_page(url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :action => action))) 121 122 if options.is_a?(Hash) 123 if options[:action].is_a?(Array) 124 options[:action].dup.each do |action| 125 self.class.expire_page(url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :action => action))) 126 end 127 else 128 self.class.expire_page(url_for(options.merge(:only_path => true, :skip_relative_url_root => true))) 124 129 end 125 130 else 126 self.class.expire_page( url_for(options.merge(:only_path => true, :skip_relative_url_root => true)))131 self.class.expire_page(options) 127 132 end 128 133 end … … 133 138 def cache_page(content = nil, options = {}) 134 139 return unless perform_caching && caching_allowed 135 self.class.cache_page(content || response.body, url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format]))) 140 141 if options.is_a?(Hash) 142 path = url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format])) 143 else 144 path = options 145 end 146 147 self.class.cache_page(content || response.body, path) 136 148 end 137 149 trunk/actionpack/test/abstract_unit.rb
r6740 r6868 9 9 require 'action_controller/cgi_ext' 10 10 require 'action_controller/test_process' 11 12 require 'ruby-debug' 11 13 12 14 # Show backtraces for deprecated behavior for quicker cleanup. trunk/actionpack/test/controller/caching_test.rb
r6867 r6868 26 26 head :not_found 27 27 end 28 29 def custom_path 30 render :text => "Super soaker" 31 cache_page("Super soaker", "/index.html") 32 end 33 34 def expire_custom_path 35 expire_page("/index.html") 36 head :ok 37 end 28 38 end 29 39 … … 68 78 assert_response :ok 69 79 assert_page_cached :ok, "get with ok status should have been cached" 80 end 81 82 def test_should_cache_with_custom_path 83 get :custom_path 84 assert File.exist?("#{FILE_STORE_PATH}/index.html") 85 end 86 87 def test_should_expire_cache_with_custom_path 88 get :custom_path 89 assert File.exist?("#{FILE_STORE_PATH}/index.html") 90 91 get :expire_custom_path 92 assert !File.exist?("#{FILE_STORE_PATH}/index.html") 70 93 end 71 94 … … 97 120 end 98 121 122 99 123 class ActionCachingTestController < ActionController::Base 100 124 caches_action :index