actionmailer 7.0.4 → 7.1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +150 -27
- data/MIT-LICENSE +1 -1
- data/README.rdoc +4 -4
- data/lib/action_mailer/base.rb +60 -48
- data/lib/action_mailer/callbacks.rb +31 -0
- data/lib/action_mailer/delivery_methods.rb +5 -3
- data/lib/action_mailer/deprecator.rb +7 -0
- data/lib/action_mailer/form_builder.rb +37 -0
- data/lib/action_mailer/gem_version.rb +4 -4
- data/lib/action_mailer/inline_preview_interceptor.rb +2 -0
- data/lib/action_mailer/log_subscriber.rb +7 -2
- data/lib/action_mailer/mail_delivery_job.rb +7 -2
- data/lib/action_mailer/mail_helper.rb +13 -3
- data/lib/action_mailer/message_delivery.rb +20 -12
- data/lib/action_mailer/parameterized.rb +7 -1
- data/lib/action_mailer/preview.rb +32 -8
- data/lib/action_mailer/queued_delivery.rb +12 -0
- data/lib/action_mailer/railtie.rb +11 -16
- data/lib/action_mailer/rescuable.rb +6 -2
- data/lib/action_mailer/test_case.rb +9 -4
- data/lib/action_mailer/test_helper.rb +134 -11
- data/lib/action_mailer/version.rb +1 -1
- data/lib/action_mailer.rb +11 -2
- data/lib/rails/generators/mailer/USAGE +12 -8
- metadata +23 -19
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionMailer
|
4
|
+
module Callbacks
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
include ActiveSupport::Callbacks
|
9
|
+
define_callbacks :deliver, skip_after_callbacks_if_terminated: true
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
# Defines a callback that will get called right before the
|
14
|
+
# message is sent to the delivery method.
|
15
|
+
def before_deliver(*filters, &blk)
|
16
|
+
set_callback(:deliver, :before, *filters, &blk)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Defines a callback that will get called right after the
|
20
|
+
# message's delivery method is finished.
|
21
|
+
def after_deliver(*filters, &blk)
|
22
|
+
set_callback(:deliver, :after, *filters, &blk)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Defines a callback that will get called around the message's deliver method.
|
26
|
+
def around_deliver(*filters, &blk)
|
27
|
+
set_callback(:deliver, :around, *filters, &blk)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require "tmpdir"
|
4
4
|
|
5
5
|
module ActionMailer
|
6
|
+
# = Action Mailer \DeliveryMethods
|
7
|
+
#
|
6
8
|
# This module handles everything related to mail delivery, from registering
|
7
9
|
# new delivery methods to configuring the mail object to be sent.
|
8
10
|
module DeliveryMethods
|
@@ -12,7 +14,6 @@ module ActionMailer
|
|
12
14
|
# Do not make this inheritable, because we always want it to propagate
|
13
15
|
cattr_accessor :raise_delivery_errors, default: true
|
14
16
|
cattr_accessor :perform_deliveries, default: true
|
15
|
-
cattr_accessor :deliver_later_queue_name, default: :mailers
|
16
17
|
|
17
18
|
class_attribute :delivery_methods, default: {}.freeze
|
18
19
|
class_attribute :delivery_method, default: :smtp
|
@@ -31,7 +32,8 @@ module ActionMailer
|
|
31
32
|
|
32
33
|
add_delivery_method :sendmail, Mail::Sendmail,
|
33
34
|
location: "/usr/sbin/sendmail",
|
34
|
-
|
35
|
+
# See breaking change in the mail gem - https://github.com/mikel/mail/commit/7e1196bd29815a0901d7290c82a332c0959b163a
|
36
|
+
arguments: Gem::Version.new(Mail::VERSION.version) >= Gem::Version.new("2.8.0") ? %w[-i] : "-i"
|
35
37
|
|
36
38
|
add_delivery_method :test, Mail::TestMailer
|
37
39
|
end
|
@@ -46,7 +48,7 @@ module ActionMailer
|
|
46
48
|
#
|
47
49
|
# add_delivery_method :sendmail, Mail::Sendmail,
|
48
50
|
# location: '/usr/sbin/sendmail',
|
49
|
-
# arguments:
|
51
|
+
# arguments: %w[ -i ]
|
50
52
|
def add_delivery_method(symbol, klass, default_options = {})
|
51
53
|
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
|
52
54
|
public_send(:"#{symbol}_settings=", default_options)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionMailer
|
4
|
+
# = Action Mailer Form Builder
|
5
|
+
#
|
6
|
+
# Override the default form builder for all views rendered by this
|
7
|
+
# mailer and any of its descendants. Accepts a subclass of
|
8
|
+
# ActionView::Helpers::FormBuilder.
|
9
|
+
#
|
10
|
+
# While emails typically will not include forms, this can be used
|
11
|
+
# by views that are shared between controllers and mailers.
|
12
|
+
#
|
13
|
+
# For more information, see +ActionController::FormBuilder+.
|
14
|
+
module FormBuilder
|
15
|
+
extend ActiveSupport::Concern
|
16
|
+
|
17
|
+
included do
|
18
|
+
class_attribute :_default_form_builder, instance_accessor: false
|
19
|
+
end
|
20
|
+
|
21
|
+
module ClassMethods
|
22
|
+
# Set the form builder to be used as the default for all forms
|
23
|
+
# in the views rendered by this mailer and its subclasses.
|
24
|
+
#
|
25
|
+
# ==== Parameters
|
26
|
+
# * <tt>builder</tt> - Default form builder, an instance of ActionView::Helpers::FormBuilder
|
27
|
+
def default_form_builder(builder)
|
28
|
+
self._default_form_builder = builder
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Default form builder for the mailer
|
33
|
+
def default_form_builder
|
34
|
+
self.class._default_form_builder
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActionMailer
|
4
|
-
# Returns the currently loaded version of Action Mailer as a
|
4
|
+
# Returns the currently loaded version of Action Mailer as a +Gem::Version+.
|
5
5
|
def self.gem_version
|
6
6
|
Gem::Version.new VERSION::STRING
|
7
7
|
end
|
8
8
|
|
9
9
|
module VERSION
|
10
10
|
MAJOR = 7
|
11
|
-
MINOR =
|
12
|
-
TINY =
|
13
|
-
PRE =
|
11
|
+
MINOR = 1
|
12
|
+
TINY = 5
|
13
|
+
PRE = "1"
|
14
14
|
|
15
15
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
16
16
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require "base64"
|
4
4
|
|
5
5
|
module ActionMailer
|
6
|
+
# = Action Mailer \InlinePreviewInterceptor
|
7
|
+
#
|
6
8
|
# Implements a mailer preview interceptor that converts image tag src attributes
|
7
9
|
# that use inline cid: style URLs to data: style URLs so that they are visible
|
8
10
|
# when previewing an HTML email in a web browser.
|
@@ -3,14 +3,17 @@
|
|
3
3
|
require "active_support/log_subscriber"
|
4
4
|
|
5
5
|
module ActionMailer
|
6
|
+
# = Action Mailer \LogSubscriber
|
7
|
+
#
|
6
8
|
# Implements the ActiveSupport::LogSubscriber for logging notifications when
|
7
9
|
# email is delivered or received.
|
8
10
|
class LogSubscriber < ActiveSupport::LogSubscriber
|
9
11
|
# An email was delivered.
|
10
12
|
def deliver(event)
|
11
13
|
info do
|
12
|
-
|
13
|
-
|
14
|
+
if exception = event.payload[:exception_object]
|
15
|
+
"Failed delivery of mail #{event.payload[:message_id]} error_class=#{exception.class} error_message=#{exception.message.inspect}"
|
16
|
+
elsif event.payload[:perform_deliveries]
|
14
17
|
"Delivered mail #{event.payload[:message_id]} (#{event.duration.round(1)}ms)"
|
15
18
|
else
|
16
19
|
"Skipped delivery of mail #{event.payload[:message_id]} as `perform_deliveries` is false"
|
@@ -19,6 +22,7 @@ module ActionMailer
|
|
19
22
|
|
20
23
|
debug { event.payload[:mail] }
|
21
24
|
end
|
25
|
+
subscribe_log_level :deliver, :debug
|
22
26
|
|
23
27
|
# An email was generated.
|
24
28
|
def process(event)
|
@@ -28,6 +32,7 @@ module ActionMailer
|
|
28
32
|
"#{mailer}##{action}: processed outbound mail in #{event.duration.round(1)}ms"
|
29
33
|
end
|
30
34
|
end
|
35
|
+
subscribe_log_level :process, :debug
|
31
36
|
|
32
37
|
# Use the logger configured for ActionMailer::Base.
|
33
38
|
def logger
|
@@ -3,13 +3,18 @@
|
|
3
3
|
require "active_job"
|
4
4
|
|
5
5
|
module ActionMailer
|
6
|
-
#
|
6
|
+
# = Action Mailer \MailDeliveryJob
|
7
|
+
#
|
8
|
+
# The +ActionMailer::MailDeliveryJob+ class is used when you
|
7
9
|
# want to send emails outside of the request-response cycle. It supports
|
8
10
|
# sending either parameterized or normal mail.
|
9
11
|
#
|
10
12
|
# Exceptions are rescued and handled by the mailer class.
|
11
13
|
class MailDeliveryJob < ActiveJob::Base # :nodoc:
|
12
|
-
queue_as
|
14
|
+
queue_as do
|
15
|
+
mailer_class = arguments.first.constantize
|
16
|
+
mailer_class.deliver_later_queue_name
|
17
|
+
end
|
13
18
|
|
14
19
|
rescue_from StandardError, with: :handle_exception_with_mailer_class
|
15
20
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActionMailer
|
4
|
+
# = Action Mailer \MailHelper
|
5
|
+
#
|
4
6
|
# Provides helper methods for ActionMailer::Base that can be used for easily
|
5
7
|
# formatting messages, accessing mailer or message instances, and the
|
6
8
|
# attachments list.
|
@@ -23,10 +25,18 @@ module ActionMailer
|
|
23
25
|
}.join("\n\n")
|
24
26
|
|
25
27
|
# Make list points stand on their own line
|
26
|
-
|
27
|
-
formatted.
|
28
|
+
output = +""
|
29
|
+
splits = formatted.split(/(\*+|\#+)/)
|
30
|
+
while line = splits.shift
|
31
|
+
if line.start_with?("*", "#") && splits.first&.start_with?(" ")
|
32
|
+
output.chomp!(" ") while output.end_with?(" ")
|
33
|
+
output << " #{line} #{splits.shift.strip}\n"
|
34
|
+
else
|
35
|
+
output << line
|
36
|
+
end
|
37
|
+
end
|
28
38
|
|
29
|
-
|
39
|
+
output
|
30
40
|
end
|
31
41
|
|
32
42
|
# Access the mailer instance.
|
@@ -3,11 +3,13 @@
|
|
3
3
|
require "delegate"
|
4
4
|
|
5
5
|
module ActionMailer
|
6
|
-
#
|
6
|
+
# = Action Mailer \MessageDelivery
|
7
|
+
#
|
8
|
+
# The +ActionMailer::MessageDelivery+ class is used by
|
7
9
|
# ActionMailer::Base when creating a new mailer.
|
8
10
|
# <tt>MessageDelivery</tt> is a wrapper (+Delegator+ subclass) around a lazy
|
9
|
-
# created
|
10
|
-
#
|
11
|
+
# created +Mail::Message+. You can get direct access to the
|
12
|
+
# +Mail::Message+, deliver the email or schedule the email to be sent
|
11
13
|
# through Active Job.
|
12
14
|
#
|
13
15
|
# Notifier.welcome(User.first) # an ActionMailer::MessageDelivery object
|
@@ -62,9 +64,10 @@ module ActionMailer
|
|
62
64
|
# * <tt>:queue</tt> - Enqueue the email on the specified queue
|
63
65
|
# * <tt>:priority</tt> - Enqueues the email with the specified priority
|
64
66
|
#
|
65
|
-
# By default, the email will be enqueued using
|
66
|
-
#
|
67
|
-
# +
|
67
|
+
# By default, the email will be enqueued using ActionMailer::MailDeliveryJob on
|
68
|
+
# the default queue. Mailer classes can customize the queue name used for the default
|
69
|
+
# job by assigning a +deliver_later_queue_name+ class variable, or provide a custom job
|
70
|
+
# by assigning a +delivery_job+. When a custom job is used, it controls the queue name.
|
68
71
|
#
|
69
72
|
# class AccountRegistrationMailer < ApplicationMailer
|
70
73
|
# self.delivery_job = RegistrationDeliveryJob
|
@@ -88,9 +91,10 @@ module ActionMailer
|
|
88
91
|
# * <tt>:queue</tt> - Enqueue the email on the specified queue.
|
89
92
|
# * <tt>:priority</tt> - Enqueues the email with the specified priority
|
90
93
|
#
|
91
|
-
# By default, the email will be enqueued using
|
92
|
-
#
|
93
|
-
# +
|
94
|
+
# By default, the email will be enqueued using ActionMailer::MailDeliveryJob on
|
95
|
+
# the default queue. Mailer classes can customize the queue name used for the default
|
96
|
+
# job by assigning a +deliver_later_queue_name+ class variable, or provide a custom job
|
97
|
+
# by assigning a +delivery_job+. When a custom job is used, it controls the queue name.
|
94
98
|
#
|
95
99
|
# class AccountRegistrationMailer < ApplicationMailer
|
96
100
|
# self.delivery_job = RegistrationDeliveryJob
|
@@ -106,7 +110,9 @@ module ActionMailer
|
|
106
110
|
#
|
107
111
|
def deliver_now!
|
108
112
|
processed_mailer.handle_exceptions do
|
109
|
-
|
113
|
+
processed_mailer.run_callbacks(:deliver) do
|
114
|
+
message.deliver!
|
115
|
+
end
|
110
116
|
end
|
111
117
|
end
|
112
118
|
|
@@ -116,13 +122,15 @@ module ActionMailer
|
|
116
122
|
#
|
117
123
|
def deliver_now
|
118
124
|
processed_mailer.handle_exceptions do
|
119
|
-
|
125
|
+
processed_mailer.run_callbacks(:deliver) do
|
126
|
+
message.deliver
|
127
|
+
end
|
120
128
|
end
|
121
129
|
end
|
122
130
|
|
123
131
|
private
|
124
132
|
# Returns the processed Mailer instance. We keep this instance
|
125
|
-
# on hand so we can delegate exception handling to it.
|
133
|
+
# on hand so we can run callbacks and delegate exception handling to it.
|
126
134
|
def processed_mailer
|
127
135
|
@processed_mailer ||= @mailer_class.new.tap do |mailer|
|
128
136
|
mailer.process @action, *@args
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActionMailer
|
4
|
+
# = Action Mailer \Parameterized
|
5
|
+
#
|
4
6
|
# Provides the option to parameterize mailers in order to share instance variable
|
5
7
|
# setup, processing, and common headers.
|
6
8
|
#
|
@@ -88,7 +90,11 @@ module ActionMailer
|
|
88
90
|
extend ActiveSupport::Concern
|
89
91
|
|
90
92
|
included do
|
91
|
-
|
93
|
+
attr_writer :params
|
94
|
+
|
95
|
+
def params
|
96
|
+
@params ||= {}
|
97
|
+
end
|
92
98
|
end
|
93
99
|
|
94
100
|
module ClassMethods
|
@@ -7,11 +7,11 @@ module ActionMailer
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
#
|
10
|
+
# Add the location of mailer previews through app configuration:
|
11
11
|
#
|
12
|
-
# config.action_mailer.
|
12
|
+
# config.action_mailer.preview_paths << "#{Rails.root}/lib/mailer_previews"
|
13
13
|
#
|
14
|
-
mattr_accessor :
|
14
|
+
mattr_accessor :preview_paths, instance_writer: false, default: []
|
15
15
|
|
16
16
|
# Enable or disable mailer previews through app configuration:
|
17
17
|
#
|
@@ -25,7 +25,31 @@ module ActionMailer
|
|
25
25
|
mattr_accessor :preview_interceptors, instance_writer: false, default: [ActionMailer::InlinePreviewInterceptor]
|
26
26
|
end
|
27
27
|
|
28
|
+
def preview_path
|
29
|
+
ActionMailer.deprecator.warn(<<-MSG.squish)
|
30
|
+
Using preview_path option is deprecated and will be removed in Rails 7.2.
|
31
|
+
Please use preview_paths instead.
|
32
|
+
MSG
|
33
|
+
self.class.preview_paths.first
|
34
|
+
end
|
35
|
+
|
28
36
|
module ClassMethods
|
37
|
+
def preview_path=(value)
|
38
|
+
ActionMailer.deprecator.warn(<<-MSG.squish)
|
39
|
+
Using preview_path= option is deprecated and will be removed in Rails 7.2.
|
40
|
+
Please use preview_paths= instead.
|
41
|
+
MSG
|
42
|
+
self.preview_paths << value
|
43
|
+
end
|
44
|
+
|
45
|
+
def preview_path
|
46
|
+
ActionMailer.deprecator.warn(<<-MSG.squish)
|
47
|
+
Using preview_path option is deprecated and will be removed in Rails 7.2.
|
48
|
+
Please use preview_paths instead.
|
49
|
+
MSG
|
50
|
+
self.preview_paths.first
|
51
|
+
end
|
52
|
+
|
29
53
|
# Register one or more Interceptors which will be called before mail is previewed.
|
30
54
|
def register_preview_interceptors(*interceptors)
|
31
55
|
interceptors.flatten.compact.each { |interceptor| register_preview_interceptor(interceptor) }
|
@@ -79,7 +103,7 @@ module ActionMailer
|
|
79
103
|
# Returns all mailer preview classes.
|
80
104
|
def all
|
81
105
|
load_previews if descendants.empty?
|
82
|
-
descendants
|
106
|
+
descendants.sort_by { |mailer| mailer.name.titleize }
|
83
107
|
end
|
84
108
|
|
85
109
|
# Returns the mail object for the given email name. The registered preview
|
@@ -119,13 +143,13 @@ module ActionMailer
|
|
119
143
|
|
120
144
|
private
|
121
145
|
def load_previews
|
122
|
-
|
123
|
-
Dir["#{preview_path}/**/*_preview.rb"].sort.each { |file|
|
146
|
+
preview_paths.each do |preview_path|
|
147
|
+
Dir["#{preview_path}/**/*_preview.rb"].sort.each { |file| require file }
|
124
148
|
end
|
125
149
|
end
|
126
150
|
|
127
|
-
def
|
128
|
-
Base.
|
151
|
+
def preview_paths
|
152
|
+
Base.preview_paths
|
129
153
|
end
|
130
154
|
|
131
155
|
def show_previews
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionMailer
|
4
|
+
module QueuedDelivery
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
class_attribute :delivery_job, default: ::ActionMailer::MailDeliveryJob
|
9
|
+
class_attribute :deliver_later_queue_name, default: :mailers
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -8,8 +8,13 @@ require "abstract_controller/railties/routes_helpers"
|
|
8
8
|
module ActionMailer
|
9
9
|
class Railtie < Rails::Railtie # :nodoc:
|
10
10
|
config.action_mailer = ActiveSupport::OrderedOptions.new
|
11
|
+
config.action_mailer.preview_paths = []
|
11
12
|
config.eager_load_namespaces << ActionMailer
|
12
13
|
|
14
|
+
initializer "action_mailer.deprecator", before: :load_environment_config do |app|
|
15
|
+
app.deprecators[:action_mailer] = ActionMailer.deprecator
|
16
|
+
end
|
17
|
+
|
13
18
|
initializer "action_mailer.logger" do
|
14
19
|
ActiveSupport.on_load(:action_mailer) { self.logger ||= Rails.logger }
|
15
20
|
end
|
@@ -23,10 +28,7 @@ module ActionMailer
|
|
23
28
|
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
24
29
|
options.show_previews = Rails.env.development? if options.show_previews.nil?
|
25
30
|
options.cache_store ||= Rails.cache
|
26
|
-
|
27
|
-
if options.show_previews
|
28
|
-
options.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil
|
29
|
-
end
|
31
|
+
options.preview_paths |= ["#{Rails.root}/test/mailers/previews"]
|
30
32
|
|
31
33
|
# make sure readers methods get compiled
|
32
34
|
options.asset_host ||= app.config.asset_host
|
@@ -40,6 +42,7 @@ module ActionMailer
|
|
40
42
|
register_interceptors(options.delete(:interceptors))
|
41
43
|
register_preview_interceptors(options.delete(:preview_interceptors))
|
42
44
|
register_observers(options.delete(:observers))
|
45
|
+
self.preview_paths |= options[:preview_paths]
|
43
46
|
|
44
47
|
if delivery_job = options.delete(:delivery_job)
|
45
48
|
self.delivery_job = delivery_job.constantize
|
@@ -65,12 +68,9 @@ module ActionMailer
|
|
65
68
|
end
|
66
69
|
end
|
67
70
|
|
68
|
-
initializer "action_mailer.set_autoload_paths" do |app|
|
71
|
+
initializer "action_mailer.set_autoload_paths", before: :set_autoload_paths do |app|
|
69
72
|
options = app.config.action_mailer
|
70
|
-
|
71
|
-
if options.show_previews && options.preview_path
|
72
|
-
ActiveSupport::Dependencies.autoload_paths << options.preview_path
|
73
|
-
end
|
73
|
+
app.config.paths["test/mailers/previews"].concat(options.preview_paths)
|
74
74
|
end
|
75
75
|
|
76
76
|
initializer "action_mailer.compile_config_methods" do
|
@@ -79,18 +79,13 @@ module ActionMailer
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
initializer "action_mailer.eager_load_actions" do
|
83
|
-
ActiveSupport.on_load(:after_initialize) do
|
84
|
-
ActionMailer::Base.descendants.each(&:action_methods) if config.eager_load
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
82
|
config.after_initialize do |app|
|
89
83
|
options = app.config.action_mailer
|
90
84
|
|
91
85
|
if options.show_previews
|
92
86
|
app.routes.prepend do
|
93
|
-
get "/rails/mailers"
|
87
|
+
get "/rails/mailers" => "rails/mailers#index", internal: true
|
88
|
+
get "/rails/mailers/download/*path" => "rails/mailers#download", internal: true
|
94
89
|
get "/rails/mailers/*path" => "rails/mailers#preview", internal: true
|
95
90
|
end
|
96
91
|
end
|
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActionMailer # :nodoc:
|
4
|
-
#
|
5
|
-
#
|
4
|
+
# = Action Mailer \Rescuable
|
5
|
+
#
|
6
|
+
# Provides
|
7
|
+
# {rescue_from}[rdoc-ref:ActiveSupport::Rescuable::ClassMethods#rescue_from]
|
8
|
+
# for mailers. Wraps mailer action processing, mail job processing, and mail
|
9
|
+
# delivery to handle configured errors.
|
6
10
|
module Rescuable
|
7
11
|
extend ActiveSupport::Concern
|
8
12
|
include ActiveSupport::Rescuable
|
@@ -74,6 +74,15 @@ module ActionMailer
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
# Reads the fixture file for the given mailer.
|
78
|
+
#
|
79
|
+
# This is useful when testing mailers by being able to write the body of
|
80
|
+
# an email inside a fixture. See the testing guide for a concrete example:
|
81
|
+
# https://guides.rubyonrails.org/testing.html#revenge-of-the-fixtures
|
82
|
+
def read_fixture(action)
|
83
|
+
IO.readlines(File.join(Rails.root, "test", "fixtures", self.class.mailer_class.name.underscore, action))
|
84
|
+
end
|
85
|
+
|
77
86
|
private
|
78
87
|
def initialize_test_deliveries
|
79
88
|
set_delivery_method :test
|
@@ -110,10 +119,6 @@ module ActionMailer
|
|
110
119
|
def encode(subject)
|
111
120
|
Mail::Encodings.q_value_encode(subject, charset)
|
112
121
|
end
|
113
|
-
|
114
|
-
def read_fixture(action)
|
115
|
-
IO.readlines(File.join(Rails.root, "test", "fixtures", self.class.mailer_class.name.underscore, action))
|
116
|
-
end
|
117
122
|
end
|
118
123
|
|
119
124
|
include Behavior
|