diff options
author | Dave Gynn <davegynn@gmail.com> | 2015-12-26 22:25:27 -0800 |
---|---|---|
committer | Dave Gynn <davegynn@gmail.com> | 2015-12-26 22:37:31 -0800 |
commit | 837e40dcac023319a0bfc38240761d4352b73b99 (patch) | |
tree | 3b98c30c02e7f01d41e7902aa72e85c168de2068 | |
parent | c56e56773815221ef1fbd127f949c3e5207ea471 (diff) | |
download | rails-837e40dcac023319a0bfc38240761d4352b73b99.tar.gz rails-837e40dcac023319a0bfc38240761d4352b73b99.tar.bz2 rails-837e40dcac023319a0bfc38240761d4352b73b99.zip |
restore ability to pass extra options to cache stores
The `cache` helper methods should pass any extra options
to the cache store. For example :expires_in would be a
valid option if memcache was the cache store. The change
in commit da16745 broke the ability to pass any options
other than :skip_digest and :virtual_path. This PR
restores that functionality and adds a test for it.
3 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index d19b3810c2..74c78dfa8e 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -172,6 +172,9 @@ class FunctionalCachingController < CachingController def fragment_cached_without_digest end + + def fragment_cached_with_options + end end class FunctionalFragmentCachingTest < ActionController::TestCase @@ -215,6 +218,15 @@ CACHED assert_equal "<p>ERB</p>", @store.read("views/nodigest") end + def test_fragment_caching_with_options + get :fragment_cached_with_options + assert_response :success + expected_body = "<body>\n<p>ERB</p>\n</body>\n" + + assert_equal expected_body, @response.body + assert_equal "<p>ERB</p>", @store.read("views/with_options") + end + def test_render_inline_before_fragment_caching get :inline_fragment_cached assert_response :success diff --git a/actionpack/test/fixtures/functional_caching/fragment_cached_with_options.html.erb b/actionpack/test/fixtures/functional_caching/fragment_cached_with_options.html.erb new file mode 100644 index 0000000000..6865df9b7e --- /dev/null +++ b/actionpack/test/fixtures/functional_caching/fragment_cached_with_options.html.erb @@ -0,0 +1,3 @@ +<body> +<%= cache 'with_options', :skip_digest => true, :expires_in => 1.minute do %><p>ERB</p><% end %> +</body> diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb index 18b2102d73..2e30578123 100644 --- a/actionview/lib/action_view/helpers/cache_helper.rb +++ b/actionview/lib/action_view/helpers/cache_helper.rb @@ -208,7 +208,7 @@ module ActionView # # The digest will be generated using +virtual_path:+ if it is provided. # - def cache_fragment_name(name = {}, skip_digest: nil, virtual_path: nil) + def cache_fragment_name(name = {}, skip_digest: nil, virtual_path: nil, **_options) if skip_digest name else |