Skip to content

Commit

Permalink
rename page_cache_extension option to default_static_extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Rodriguez committed Oct 3, 2012
1 parent 2f81be1 commit e4d5b69
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
22 changes: 12 additions & 10 deletions actionpack/lib/action_controller/caching.rb
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/middleware/static.rb
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions actionpack/test/controller/caching_test.rb
Expand Up @@ -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

0 comments on commit e4d5b69

Please sign in to comment.