Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rename page_cache_extension option to default_static_extension

  • Loading branch information...
commit e4d5b69b57c21e334a0b26dbc90a9b6bca044781 1 parent 2f81be1
Francesco Rodriguez authored
View
22 actionpack/lib/action_controller/caching.rb
@@ -59,16 +59,18 @@ def cache_configured?
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?
View
2  actionpack/lib/action_dispatch/middleware/static.rb
@@ -29,7 +29,7 @@ def call(env)
def ext
@ext ||= begin
- ext = ::ActionController::Base.page_cache_extension
+ ext = ::ActionController::Base.default_static_extension
"{,#{ext},/index#{ext}}"
end
end
View
15 actionpack/test/controller/caching_test.rb
@@ -283,3 +283,18 @@ def test_safe_buffer
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
Please sign in to comment.
Something went wrong with that request. Please try again.