Make ActionMailer #cache helper a no-op, not an exception

This commit is contained in:
Javan Makhmali 2015-04-28 09:46:17 -06:00
parent 7bc45df182
commit 20f6f646d1
2 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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