mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #22800 from dgynn/pr_cache_helper_options
Restore ability to pass extra options to cache stores
This commit is contained in:
commit
f16709231d
3 changed files with 16 additions and 1 deletions
|
@ -172,6 +172,9 @@ class FunctionalCachingController < CachingController
|
||||||
|
|
||||||
def fragment_cached_without_digest
|
def fragment_cached_without_digest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fragment_cached_with_options
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class FunctionalFragmentCachingTest < ActionController::TestCase
|
class FunctionalFragmentCachingTest < ActionController::TestCase
|
||||||
|
@ -215,6 +218,15 @@ CACHED
|
||||||
assert_equal "<p>ERB</p>", @store.read("views/nodigest")
|
assert_equal "<p>ERB</p>", @store.read("views/nodigest")
|
||||||
end
|
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
|
def test_render_inline_before_fragment_caching
|
||||||
get :inline_fragment_cached
|
get :inline_fragment_cached
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
3
actionpack/test/fixtures/functional_caching/fragment_cached_with_options.html.erb
vendored
Normal file
3
actionpack/test/fixtures/functional_caching/fragment_cached_with_options.html.erb
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<body>
|
||||||
|
<%= cache 'with_options', skip_digest: true, expires_in: 1.minute do %><p>ERB</p><% end %>
|
||||||
|
</body>
|
|
@ -208,7 +208,7 @@ module ActionView
|
||||||
#
|
#
|
||||||
# The digest will be generated using +virtual_path:+ if it is provided.
|
# 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
|
if skip_digest
|
||||||
name
|
name
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue