提交 f4b8b58f 编写于 作者: R Rafael Mendonça França

Merge pull request #19941 from javan/actionmailer-cache-noop

Make ActionMailer #cache helper a no-op, not an exception
......@@ -59,6 +59,12 @@ def use_block_format
end
end
def use_cache
mail_with_defaults do |format|
format.html { render(inline: "<% cache(:foo) do %>Greetings from a cache helper block<% end %>") }
end
end
protected
def mail_with_defaults(&block)
......@@ -107,5 +113,11 @@ def test_use_block_format
TEXT
assert_equal expected.gsub("\n", "\r\n"), mail.body.encoded
end
end
def test_use_cache
assert_nothing_raised do
mail = HelperMailer.use_cache
assert_equal "Greetings from a cache helper block", mail.body.encoded
end
end
end
......@@ -134,7 +134,7 @@ module CacheHelper
#
# <%= render @notifications, cache: false %>
def cache(name = {}, options = nil, &block)
if controller.perform_caching
if controller.respond_to?(:perform_caching) && controller.perform_caching
safe_concat(fragment_for(cache_fragment_name(name, options), options, &block))
else
yield
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册