diff options
-rw-r--r-- | actionpack/lib/action_controller/caching.rb | 22 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/caching_test.rb | 15 |
3 files changed, 28 insertions, 11 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index c354123206..462f147371 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -59,16 +59,18 @@ module ActionController included do extend ConfigMethods - # Most Rails requests do not have an extension, such as <tt>/weblog/new</tt>. - # In these cases, the page caching mechanism will add one in order to make it - # easy for the cached files to be picked up properly by the web server. By - # default, this cache extension is <tt>.html</tt>. If you want something else, - # like <tt>.php</tt> or <tt>.shtml</tt>, just set Base.page_cache_extension. - # In cases where a request already has an extension, such as <tt>.xml</tt> - # or <tt>.rss</tt>, page caching will not add an extension. This allows it - # to work well with RESTful apps. - config_accessor :page_cache_extension - self.page_cache_extension ||= '.html' + config_accessor :default_static_extension + self.default_static_extension ||= '.html' + + def self.page_cache_extension=(extension) + ActiveSupport::Deprecation.deprecation_warning(:page_cache_extension, :default_static_extension) + self.default_static_extension = extension + end + + def self.page_cache_extension + ActiveSupport::Deprecation.deprecation_warning(:page_cache_extension, :default_static_extension) + default_static_extension + end config_accessor :perform_caching self.perform_caching = true if perform_caching.nil? diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 9073e6582d..e3b15b43b9 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -29,7 +29,7 @@ module ActionDispatch def ext @ext ||= begin - ext = ::ActionController::Base.page_cache_extension + ext = ::ActionController::Base.default_static_extension "{,#{ext},/index#{ext}}" end end diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 488917e32c..65c18dfb64 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -283,3 +283,18 @@ class CacheHelperOutputBufferTest < ActionController::TestCase end end end + +class DeprecatedPageCacheExtensionTest < ActiveSupport::TestCase + def test_page_cache_extension_binds_default_static_extension + deprecation_behavior = ActiveSupport::Deprecation.behavior + ActiveSupport::Deprecation.behavior = :silence + old_extension = ActionController::Base.default_static_extension + + ActionController::Base.page_cache_extension = '.rss' + + assert_equal '.rss', ActionController::Base.default_static_extension + ensure + ActiveSupport::Deprecation.behavior = deprecation_behavior + ActionController::Base.default_static_extension = old_extension + end +end |