mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make ActionMailer #cache helper a no-op, not an exception
This commit is contained in:
parent
7bc45df182
commit
20f6f646d1
2 changed files with 14 additions and 2 deletions
|
@ -59,6 +59,12 @@ The second
|
||||||
end
|
end
|
||||||
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
|
protected
|
||||||
|
|
||||||
def mail_with_defaults(&block)
|
def mail_with_defaults(&block)
|
||||||
|
@ -107,5 +113,11 @@ class MailerHelperTest < ActionMailer::TestCase
|
||||||
TEXT
|
TEXT
|
||||||
assert_equal expected.gsub("\n", "\r\n"), mail.body.encoded
|
assert_equal expected.gsub("\n", "\r\n"), mail.body.encoded
|
||||||
end
|
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 %>
|
# <%= render @notifications, cache: false %>
|
||||||
def cache(name = {}, options = nil, &block)
|
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))
|
safe_concat(fragment_for(cache_fragment_name(name, options), options, &block))
|
||||||
else
|
else
|
||||||
yield
|
yield
|
||||||
|
|
Loading…
Reference in a new issue