diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2016-02-24 11:29:16 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2016-02-24 11:29:16 -0800 |
commit | a5776ed2b2bf8bccb083e303992a174110b3ef7f (patch) | |
tree | cfef331bdccd3742e2696a5e2f50312d2f4e132d /actionmailer/lib/action_mailer | |
parent | 0c9f5f56f7a1628c8c9ff3a91a52f17a15e31b26 (diff) | |
parent | f6fecabc0cb8ad7be3783d31656a0b10fe3b5bc7 (diff) | |
download | rails-a5776ed2b2bf8bccb083e303992a174110b3ef7f.tar.gz rails-a5776ed2b2bf8bccb083e303992a174110b3ef7f.tar.bz2 rails-a5776ed2b2bf8bccb083e303992a174110b3ef7f.zip |
Merge branch 'master' into treewip
* master: (113 commits)
remove useless method
Updated file documentation [ci skip]
changes caching guide to add note on weak etags
Don't put config.action_mailer.perform_caching entry twice in development.rb
Fix wording and wrong reference
Add Ruby formatting to CHANGELOG entry
Fix ActionView's cache section reference
Do not define methods in the included block
Add caching guide in ActionMailer basics
Add ActionMailer configuration options
Preparing for 5.0.0.beta3 release
Update 5.0 release notes
Enable tmp_restart plugin for puma
Prep release for Rails 5 beta3
[ci skip] Move collection caching changelog entry.
Ensure `drop_table` even if tests failure or interrupted
:bomb: run the test @rafaelfranca :angry:
Remove changelog entry for reverted commit
Add CHANGELOG for https://github.com/rails/rails/pull/23734 [ci skip]
No need CHANGELOG entry for #23849.
...
Diffstat (limited to 'actionmailer/lib/action_mailer')
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 13 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/gem_version.rb | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 23 |
3 files changed, 27 insertions, 11 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 4259eb0bee..559cd06d91 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -430,6 +430,7 @@ module ActionMailer include AbstractController::Translation include AbstractController::AssetPaths include AbstractController::Callbacks + include AbstractController::Caching include ActionView::Layouts @@ -947,6 +948,18 @@ module ActionMailer container.add_part(part) end + # This and #instrument_name is for caching instrument + def instrument_payload(key) + { + mailer: mailer_name, + key: key + } + end + + def instrument_name + "action_mailer" + end + ActiveSupport.run_load_hooks(:action_mailer, self) end end diff --git a/actionmailer/lib/action_mailer/gem_version.rb b/actionmailer/lib/action_mailer/gem_version.rb index a1ee5fb238..cbe5fc3e64 100644 --- a/actionmailer/lib/action_mailer/gem_version.rb +++ b/actionmailer/lib/action_mailer/gem_version.rb @@ -8,7 +8,7 @@ module ActionMailer MAJOR = 5 MINOR = 0 TINY = 0 - PRE = "beta2" + PRE = "beta3" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 22390c4953..215d0199af 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -25,6 +25,7 @@ module ActionMailer options.javascripts_dir ||= paths["public/javascripts"].first options.stylesheets_dir ||= paths["public/stylesheets"].first options.show_previews = Rails.env.development? if options.show_previews.nil? + options.cache_store ||= Rails.cache if options.show_previews options.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil @@ -45,13 +46,6 @@ module ActionMailer options.each { |k,v| send("#{k}=", v) } - if options.show_previews - app.routes.prepend do - get '/rails/mailers' => "rails/mailers#index" - get '/rails/mailers/*path' => "rails/mailers#preview" - end - end - ActionDispatch::IntegrationTest.send :include, ActionMailer::TestCase::ClearTestDeliveries end end @@ -62,9 +56,18 @@ module ActionMailer end end - config.after_initialize do - if ActionMailer::Base.preview_path - ActiveSupport::Dependencies.autoload_paths << ActionMailer::Base.preview_path + config.after_initialize do |app| + options = app.config.action_mailer + + if options.show_previews + app.routes.prepend do + get '/rails/mailers' => "rails/mailers#index", internal: true + get '/rails/mailers/*path' => "rails/mailers#preview", internal: true + end + + if options.preview_path + ActiveSupport::Dependencies.autoload_paths << options.preview_path + end end end end |