aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-04-28 16:58:34 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-04-28 16:58:34 -0300
commitf4b8b58f72cb50d329fb304201c07e8023efe32c (patch)
tree38843c00e063c6e593d4af322ea8795839c7f290
parent7bc45df1823c3aa02afc56c850c07fe2e6c1b66c (diff)
parent20f6f646d130ed3ef28f3632a76ab2502ea3b209 (diff)
downloadrails-f4b8b58f72cb50d329fb304201c07e8023efe32c.tar.gz
rails-f4b8b58f72cb50d329fb304201c07e8023efe32c.tar.bz2
rails-f4b8b58f72cb50d329fb304201c07e8023efe32c.zip
Merge pull request #19941 from javan/actionmailer-cache-noop
Make ActionMailer #cache helper a no-op, not an exception
-rw-r--r--actionmailer/test/mail_helper_test.rb14
-rw-r--r--actionview/lib/action_view/helpers/cache_helper.rb2
2 files changed, 14 insertions, 2 deletions
diff --git a/actionmailer/test/mail_helper_test.rb b/actionmailer/test/mail_helper_test.rb
index 24ccaab8df..ff6b25b0c7 100644
--- a/actionmailer/test/mail_helper_test.rb
+++ b/actionmailer/test/mail_helper_test.rb
@@ -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
diff --git a/actionview/lib/action_view/helpers/cache_helper.rb b/actionview/lib/action_view/helpers/cache_helper.rb
index 0e2a5f90f4..4fe21ca05b 100644
--- a/actionview/lib/action_view/helpers/cache_helper.rb
+++ b/actionview/lib/action_view/helpers/cache_helper.rb
@@ -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