Changeset 6970
- Timestamp:
- 06/08/07 05:01:35 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/caching.rb (modified) (1 diff)
- trunk/actionpack/test/controller/caching_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r6968 r6970 1 1 *SVN* 2 3 * Action caching is limited to GET requests returning 200 OK status. #3335 [tom@craz8.com, halfbyte, Dan Kubb, Josh Peek] 2 4 3 5 * Improve Text Helper test coverage. #7274 [Rob Sanheim, Josh Peek] trunk/actionpack/lib/action_controller/caching.rb
r6868 r6970 241 241 242 242 def after(controller) 243 return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache 243 return if !@actions.include?(controller.action_name.intern) || controller.rendered_action_cache || !caching_allowed(controller) 244 244 controller.write_fragment(controller.action_cache_path.path, controller.response.body) 245 245 end 246 246 247 247 private 248 249 248 def set_content_type!(controller, extension) 250 249 controller.response.content_type = Mime::EXTENSION_LOOKUP[extension].to_s if extension 251 250 end 252 251 253 252 def path_options_for(controller, options) 254 253 ((path_options = options[:cache_path]).respond_to?(:call) ? path_options.call(controller) : path_options) || {} 255 254 end 256 255 256 def caching_allowed(controller) 257 controller.request.get? && controller.response.headers['Status'].to_i == 200 258 end 257 259 end 258 260 trunk/actionpack/test/controller/caching_test.rb
r6868 r6970 122 122 123 123 class ActionCachingTestController < ActionController::Base 124 caches_action :index 124 caches_action :index, :redirected, :forbidden 125 125 caches_action :show, :cache_path => 'http://test.host/custom/show' 126 126 caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]};edit" : "http://test.host/edit" } … … 130 130 render :text => @cache_this 131 131 end 132 132 133 def redirected 134 redirect_to :action => 'index' 135 end 136 137 def forbidden 138 render :text => "Forbidden" 139 headers["Status"] = "403 Forbidden" 140 end 141 133 142 alias_method :show, :index 134 143 alias_method :edit, :index … … 246 255 end 247 256 257 def test_redirect_is_not_cached 258 get :redirected 259 assert_response :redirect 260 reset! 261 262 get :redirected 263 assert_response :redirect 264 end 265 266 def test_forbidden_is_not_cached 267 get :forbidden 268 assert_response :forbidden 269 reset! 270 271 get :forbidden 272 assert_response :forbidden 273 end 274 248 275 def test_xml_version_of_resource_is_treated_as_different_cache 249 276 @mock_controller.mock_url_for = 'http://example.org/posts/'