Changeset 7598
- Timestamp:
- 09/23/07 21:56:52 (1 year ago)
- Files:
-
- trunk/actionpack/lib/action_controller/caching.rb (modified) (1 diff)
- trunk/actionpack/test/controller/caching_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/caching.rb
r7498 r7598 137 137 138 138 # Manually cache the +content+ in the key determined by +options+. If no content is provided, the contents of response.body is used 139 # If no options are provided, the current +options+ for this actionis used. Example:139 # If no options are provided, the requested url is used. Example: 140 140 # cache_page "I'm the cached content", :controller => "lists", :action => "show" 141 def cache_page(content = nil, options = {})141 def cache_page(content = nil, options = nil) 142 142 return unless perform_caching && caching_allowed 143 144 if options.is_a?(Hash) 145 path = url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format])) 146 else 147 path = options 148 end 149 143 144 path = case options 145 when Hash 146 url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format])) 147 when String 148 options 149 else 150 request.path 151 end 152 150 153 self.class.cache_page(content || response.body, path) 151 154 end trunk/actionpack/test/controller/caching_test.rb
r7348 r7598 91 91 get :expire_custom_path 92 92 assert !File.exist?("#{FILE_STORE_PATH}/index.html") 93 end 94 95 uses_mocha("should_cache_ok_at_custom_path") do 96 def test_should_cache_ok_at_custom_path 97 @request.expects(:path).returns("/index.html") 98 get :ok 99 assert_response :ok 100 assert File.exist?("#{FILE_STORE_PATH}/index.html") 101 end 93 102 end 94 103