mirror of https://github.com/rails/rails
Make ActionMailer #cache helper a no-op, not an exception
This commit is contained in:
parent
7bc45df182
commit
20f6f646d1
|
@ -59,6 +59,12 @@ The second
|
|||
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 @@ class MailerHelperTest < ActionMailer::TestCase
|
|||
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 ActionView
|
|||
#
|
||||
# <%= 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
|
||||
|
|
Loading…
Reference in New Issue