提交 e4d5b69b 编写于 作者: F Francesco Rodriguez

rename page_cache_extension option to default_static_extension

上级 2f81be17
......@@ -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?
......
......@@ -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
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册