actionmailer 6.0.1 → 6.1.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionmailer might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -62
- data/MIT-LICENSE +1 -1
- data/README.rdoc +2 -2
- data/lib/action_mailer/base.rb +49 -44
- data/lib/action_mailer/delivery_job.rb +2 -1
- data/lib/action_mailer/delivery_methods.rb +1 -1
- data/lib/action_mailer/gem_version.rb +2 -2
- data/lib/action_mailer/log_subscriber.rb +0 -6
- data/lib/action_mailer/mail_delivery_job.rb +7 -2
- data/lib/action_mailer/message_delivery.rb +33 -7
- data/lib/action_mailer/parameterized.rb +12 -11
- data/lib/action_mailer/preview.rb +1 -2
- data/lib/action_mailer/railtie.rb +0 -5
- data/lib/action_mailer/test_case.rb +0 -2
- data/lib/action_mailer/test_helper.rb +4 -4
- data/lib/action_mailer.rb +2 -1
- data/lib/rails/generators/mailer/USAGE +2 -3
- metadata +27 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c87fb481516fe6cd1ec053d5092d437c7ec43745097945145ee7b966e014187
|
4
|
+
data.tar.gz: 52d3bdafe1a1464d75edcc8242e70c0f38e92b675de283f9a17379edfa3a56f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b26649fffeae94bf02a80678c5d9ab205e507484b657ae729f757bb1ab81b92706db4691ca9abc092c1be2b6b8c247583d813840da5853e7ef0cdd376f8d519c
|
7
|
+
data.tar.gz: 68deeaa1a9f14512cdab5825e6edb9b346617289c82eed2907e807c75f81af0ed214543642c7c4aa1e712aa0a69722d948e6067005e177eb5012e146c0c5b84a
|
data/CHANGELOG.md
CHANGED
@@ -1,101 +1,58 @@
|
|
1
|
-
## Rails 6.
|
1
|
+
## Rails 6.1.4 (June 24, 2021) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails 6.
|
6
|
+
## Rails 6.1.3.2 (May 05, 2021) ##
|
7
7
|
|
8
8
|
* No changes.
|
9
9
|
|
10
10
|
|
11
|
-
## Rails 6.
|
11
|
+
## Rails 6.1.3.1 (March 26, 2021) ##
|
12
12
|
|
13
13
|
* No changes.
|
14
14
|
|
15
15
|
|
16
|
-
## Rails 6.
|
16
|
+
## Rails 6.1.3 (February 17, 2021) ##
|
17
17
|
|
18
18
|
* No changes.
|
19
19
|
|
20
20
|
|
21
|
-
## Rails 6.
|
21
|
+
## Rails 6.1.2.1 (February 10, 2021) ##
|
22
22
|
|
23
23
|
* No changes.
|
24
24
|
|
25
25
|
|
26
|
-
## Rails 6.
|
26
|
+
## Rails 6.1.2 (February 09, 2021) ##
|
27
27
|
|
28
28
|
* No changes.
|
29
29
|
|
30
30
|
|
31
|
-
## Rails 6.
|
31
|
+
## Rails 6.1.1 (January 07, 2021) ##
|
32
32
|
|
33
|
-
*
|
33
|
+
* Sets default mailer queue to `"default"` in the mail assertions.
|
34
34
|
|
35
|
-
*
|
35
|
+
*Paul Keen*
|
36
36
|
|
37
|
-
* Add `MailDeliveryJob` for delivering both regular and parameterized mail. Deprecate using `DeliveryJob` and `Parameterized::DeliveryJob`.
|
38
37
|
|
39
|
-
|
38
|
+
## Rails 6.1.0 (December 09, 2020) ##
|
40
39
|
|
41
|
-
*
|
42
|
-
|
40
|
+
* Change default queue name of the deliver (`:mailers`) job to be the job adapter's
|
41
|
+
default (`:default`).
|
43
42
|
|
44
|
-
*
|
43
|
+
*Rafael Mendonça França*
|
45
44
|
|
46
|
-
*
|
47
|
-
a template name in options hash instead of only using the action name.
|
45
|
+
* Remove deprecated `ActionMailer::Base.receive` in favor of [Action Mailbox](https://github.com/rails/rails/tree/master/actionmailbox).
|
48
46
|
|
49
|
-
*
|
47
|
+
*Rafael Mendonça França*
|
50
48
|
|
51
|
-
*
|
52
|
-
|
53
|
-
*Ricardo Díaz*
|
54
|
-
|
55
|
-
* Add `perform_deliveries` to a payload of `deliver.action_mailer` notification.
|
56
|
-
|
57
|
-
*Yoshiyuki Kinjo*
|
58
|
-
|
59
|
-
* Change delivery logging message when `perform_deliveries` is false.
|
60
|
-
|
61
|
-
*Yoshiyuki Kinjo*
|
62
|
-
|
63
|
-
* Allow call `assert_enqueued_email_with` with no block.
|
64
|
-
|
65
|
-
Example:
|
66
|
-
```
|
67
|
-
def test_email
|
68
|
-
ContactMailer.welcome.deliver_later
|
69
|
-
assert_enqueued_email_with ContactMailer, :welcome
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_email_with_arguments
|
73
|
-
ContactMailer.welcome("Hello", "Goodbye").deliver_later
|
74
|
-
assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"]
|
75
|
-
end
|
76
|
-
```
|
49
|
+
* Fix ActionMailer assertions don't work for parameterized mail with legacy delivery job.
|
77
50
|
|
78
51
|
*bogdanvlviv*
|
79
52
|
|
80
|
-
*
|
81
|
-
|
82
|
-
*Samuel Cochran*
|
83
|
-
|
84
|
-
* Perform email jobs in `assert_emails`.
|
85
|
-
|
86
|
-
*Gannon McGibbon*
|
87
|
-
|
88
|
-
* Add `Base.unregister_observer`, `Base.unregister_observers`,
|
89
|
-
`Base.unregister_interceptor`, `Base.unregister_interceptors`,
|
90
|
-
`Base.unregister_preview_interceptor` and `Base.unregister_preview_interceptors`.
|
91
|
-
This makes it possible to dynamically add and remove email observers and
|
92
|
-
interceptors at runtime in the same way they're registered.
|
93
|
-
|
94
|
-
*Claudio Ortolina*, *Kota Miyake*
|
95
|
-
|
96
|
-
* Rails 6 requires Ruby 2.5.0 or newer.
|
53
|
+
* Added `email_address_with_name` to properly escape addresses with names.
|
97
54
|
|
98
|
-
*
|
55
|
+
*Sunny Ripert*
|
99
56
|
|
100
57
|
|
101
|
-
Please check [
|
58
|
+
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionmailer/CHANGELOG.md) for previous changes.
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -116,7 +116,7 @@ The latest version of Action Mailer can be installed with RubyGems:
|
|
116
116
|
|
117
117
|
Source code can be downloaded as part of the Rails project on GitHub:
|
118
118
|
|
119
|
-
* https://github.com/rails/rails/tree/
|
119
|
+
* https://github.com/rails/rails/tree/main/actionmailer
|
120
120
|
|
121
121
|
|
122
122
|
== License
|
@@ -138,4 +138,4 @@ Bug reports for the Ruby on Rails project can be filed here:
|
|
138
138
|
|
139
139
|
Feature requests should be discussed on the rails-core mailing list here:
|
140
140
|
|
141
|
-
* https://
|
141
|
+
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
data/lib/action_mailer/base.rb
CHANGED
@@ -16,11 +16,11 @@ module ActionMailer
|
|
16
16
|
#
|
17
17
|
# To use Action Mailer, you need to create a mailer model.
|
18
18
|
#
|
19
|
-
# $ rails generate mailer Notifier
|
19
|
+
# $ bin/rails generate mailer Notifier
|
20
20
|
#
|
21
21
|
# The generated model inherits from <tt>ApplicationMailer</tt> which in turn
|
22
22
|
# inherits from <tt>ActionMailer::Base</tt>. A mailer model defines methods
|
23
|
-
# used to generate an email message. In these methods, you can
|
23
|
+
# used to generate an email message. In these methods, you can set up variables to be used in
|
24
24
|
# the mailer views, options on the mail itself such as the <tt>:from</tt> address, and attachments.
|
25
25
|
#
|
26
26
|
# class ApplicationMailer < ActionMailer::Base
|
@@ -455,10 +455,6 @@ module ActionMailer
|
|
455
455
|
|
456
456
|
PROTECTED_IVARS = AbstractController::Rendering::DEFAULT_PROTECTED_INSTANCE_VARIABLES + [:@_action_has_layout]
|
457
457
|
|
458
|
-
def _protected_ivars # :nodoc:
|
459
|
-
PROTECTED_IVARS
|
460
|
-
end
|
461
|
-
|
462
458
|
helper ActionMailer::MailHelper
|
463
459
|
|
464
460
|
class_attribute :delivery_job, default: ::ActionMailer::DeliveryJob
|
@@ -551,32 +547,6 @@ module ActionMailer
|
|
551
547
|
# config.action_mailer.default_options = { from: "no-reply@example.org" }
|
552
548
|
alias :default_options= :default
|
553
549
|
|
554
|
-
# Receives a raw email, parses it into an email object, decodes it,
|
555
|
-
# instantiates a new mailer, and passes the email object to the mailer
|
556
|
-
# object's +receive+ method.
|
557
|
-
#
|
558
|
-
# If you want your mailer to be able to process incoming messages, you'll
|
559
|
-
# need to implement a +receive+ method that accepts the raw email string
|
560
|
-
# as a parameter:
|
561
|
-
#
|
562
|
-
# class MyMailer < ActionMailer::Base
|
563
|
-
# def receive(mail)
|
564
|
-
# # ...
|
565
|
-
# end
|
566
|
-
# end
|
567
|
-
def receive(raw_mail)
|
568
|
-
ActiveSupport::Deprecation.warn(<<~MESSAGE.squish)
|
569
|
-
ActionMailer::Base.receive is deprecated and will be removed in Rails 6.1.
|
570
|
-
Use Action Mailbox to process inbound email.
|
571
|
-
MESSAGE
|
572
|
-
|
573
|
-
ActiveSupport::Notifications.instrument("receive.action_mailer") do |payload|
|
574
|
-
mail = Mail.new(raw_mail)
|
575
|
-
set_payload_for_mail(payload, mail)
|
576
|
-
new.receive(mail)
|
577
|
-
end
|
578
|
-
end
|
579
|
-
|
580
550
|
# Wraps an email delivery inside of <tt>ActiveSupport::Notifications</tt> instrumentation.
|
581
551
|
#
|
582
552
|
# This method is actually called by the <tt>Mail::Message</tt> object itself
|
@@ -590,8 +560,15 @@ module ActionMailer
|
|
590
560
|
end
|
591
561
|
end
|
592
562
|
|
593
|
-
|
563
|
+
# Returns an email in the format "Name <email@example.com>".
|
564
|
+
def email_address_with_name(address, name)
|
565
|
+
Mail::Address.new.tap do |builder|
|
566
|
+
builder.address = address
|
567
|
+
builder.display_name = name
|
568
|
+
end.to_s
|
569
|
+
end
|
594
570
|
|
571
|
+
private
|
595
572
|
def set_payload_for_mail(payload, mail)
|
596
573
|
payload[:mail] = mail.encoded
|
597
574
|
payload[:mailer] = name
|
@@ -612,6 +589,7 @@ module ActionMailer
|
|
612
589
|
super
|
613
590
|
end
|
614
591
|
end
|
592
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
615
593
|
|
616
594
|
def respond_to_missing?(method, include_all = false)
|
617
595
|
action_methods.include?(method.to_s) || super
|
@@ -657,6 +635,11 @@ module ActionMailer
|
|
657
635
|
self.class.mailer_name
|
658
636
|
end
|
659
637
|
|
638
|
+
# Returns an email in the format "Name <email@example.com>".
|
639
|
+
def email_address_with_name(address, name)
|
640
|
+
self.class.email_address_with_name(address, name)
|
641
|
+
end
|
642
|
+
|
660
643
|
# Allows you to pass random and unusual headers to the new <tt>Mail::Message</tt>
|
661
644
|
# object which will add them to itself.
|
662
645
|
#
|
@@ -738,7 +721,7 @@ module ActionMailer
|
|
738
721
|
end
|
739
722
|
|
740
723
|
class LateAttachmentsProxy < SimpleDelegator
|
741
|
-
def inline;
|
724
|
+
def inline; self end
|
742
725
|
def []=(_name, _content); _raise_error end
|
743
726
|
|
744
727
|
private
|
@@ -859,8 +842,9 @@ module ActionMailer
|
|
859
842
|
@_mail_was_called = true
|
860
843
|
|
861
844
|
create_parts_from_responses(message, responses)
|
845
|
+
wrap_inline_attachments(message)
|
862
846
|
|
863
|
-
#
|
847
|
+
# Set up content type, reapply charset and handle parts order
|
864
848
|
message.content_type = set_content_type(message, content_type, headers[:content_type])
|
865
849
|
message.charset = charset
|
866
850
|
|
@@ -873,7 +857,6 @@ module ActionMailer
|
|
873
857
|
end
|
874
858
|
|
875
859
|
private
|
876
|
-
|
877
860
|
# Used by #mail to set the content type of the message.
|
878
861
|
#
|
879
862
|
# It will use the given +user_content_type+, or multipart if the mail
|
@@ -889,7 +872,7 @@ module ActionMailer
|
|
889
872
|
when user_content_type.present?
|
890
873
|
user_content_type
|
891
874
|
when m.has_attachments?
|
892
|
-
if m.attachments.
|
875
|
+
if m.attachments.all?(&:inline?)
|
893
876
|
["multipart", "related", params]
|
894
877
|
else
|
895
878
|
["multipart", "mixed", params]
|
@@ -907,7 +890,7 @@ module ActionMailer
|
|
907
890
|
# If the subject has interpolations, you can pass them through the +interpolations+ parameter.
|
908
891
|
def default_i18n_subject(interpolations = {}) # :doc:
|
909
892
|
mailer_scope = self.class.mailer_name.tr("/", ".")
|
910
|
-
I18n.t(:subject, interpolations.merge(scope: [mailer_scope, action_name], default: action_name.humanize))
|
893
|
+
I18n.t(:subject, **interpolations.merge(scope: [mailer_scope, action_name], default: action_name.humanize))
|
911
894
|
end
|
912
895
|
|
913
896
|
# Emails do not support relative path links.
|
@@ -916,12 +899,9 @@ module ActionMailer
|
|
916
899
|
end
|
917
900
|
|
918
901
|
def apply_defaults(headers)
|
919
|
-
default_values = self.class.default.
|
920
|
-
|
921
|
-
|
922
|
-
compute_default(value)
|
923
|
-
]
|
924
|
-
end.to_h
|
902
|
+
default_values = self.class.default.transform_values do |value|
|
903
|
+
compute_default(value)
|
904
|
+
end
|
925
905
|
|
926
906
|
headers_with_defaults = headers.reverse_merge(default_values)
|
927
907
|
headers_with_defaults[:subject] ||= default_i18n_subject
|
@@ -990,6 +970,27 @@ module ActionMailer
|
|
990
970
|
end
|
991
971
|
end
|
992
972
|
|
973
|
+
def wrap_inline_attachments(message)
|
974
|
+
# If we have both types of attachment, wrap all the inline attachments
|
975
|
+
# in multipart/related, but not the actual attachments
|
976
|
+
if message.attachments.detect(&:inline?) && message.attachments.detect { |a| !a.inline? }
|
977
|
+
related = Mail::Part.new
|
978
|
+
related.content_type = "multipart/related"
|
979
|
+
mixed = [ related ]
|
980
|
+
|
981
|
+
message.parts.each do |p|
|
982
|
+
if p.attachment? && !p.inline?
|
983
|
+
mixed << p
|
984
|
+
else
|
985
|
+
related.add_part(p)
|
986
|
+
end
|
987
|
+
end
|
988
|
+
|
989
|
+
message.parts.clear
|
990
|
+
mixed.each { |c| message.add_part(c) }
|
991
|
+
end
|
992
|
+
end
|
993
|
+
|
993
994
|
def create_parts_from_responses(m, responses)
|
994
995
|
if responses.size == 1 && !m.has_attachments?
|
995
996
|
responses[0].each { |k, v| m[k] = v }
|
@@ -1021,6 +1022,10 @@ module ActionMailer
|
|
1021
1022
|
"action_mailer"
|
1022
1023
|
end
|
1023
1024
|
|
1025
|
+
def _protected_ivars
|
1026
|
+
PROTECTED_IVARS
|
1027
|
+
end
|
1028
|
+
|
1024
1029
|
ActiveSupport.run_load_hooks(:action_mailer, self)
|
1025
1030
|
end
|
1026
1031
|
end
|
@@ -15,7 +15,7 @@ module ActionMailer
|
|
15
15
|
before_perform do
|
16
16
|
ActiveSupport::Deprecation.warn <<~MSG.squish
|
17
17
|
Sending mail with DeliveryJob and Parameterized::DeliveryJob
|
18
|
-
is deprecated and will be removed in Rails 6.
|
18
|
+
is deprecated and will be removed in Rails 6.2.
|
19
19
|
Please use MailDeliveryJob instead.
|
20
20
|
MSG
|
21
21
|
end
|
@@ -23,6 +23,7 @@ module ActionMailer
|
|
23
23
|
def perform(mailer, mail_method, delivery_method, *args) #:nodoc:
|
24
24
|
mailer.constantize.public_send(mail_method, *args).send(delivery_method)
|
25
25
|
end
|
26
|
+
ruby2_keywords(:perform) if respond_to?(:ruby2_keywords, true)
|
26
27
|
|
27
28
|
private
|
28
29
|
# "Deserialize" the mailer class name by hand in case another argument
|
@@ -49,7 +49,7 @@ module ActionMailer
|
|
49
49
|
# arguments: '-i'
|
50
50
|
def add_delivery_method(symbol, klass, default_options = {})
|
51
51
|
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
|
52
|
-
|
52
|
+
public_send(:"#{symbol}_settings=", default_options)
|
53
53
|
self.delivery_methods = delivery_methods.merge(symbol.to_sym => klass).freeze
|
54
54
|
end
|
55
55
|
|
@@ -20,12 +20,6 @@ module ActionMailer
|
|
20
20
|
debug { event.payload[:mail] }
|
21
21
|
end
|
22
22
|
|
23
|
-
# An email was received.
|
24
|
-
def receive(event)
|
25
|
-
info { "Received mail (#{event.duration.round(1)}ms)" }
|
26
|
-
debug { event.payload[:mail] }
|
27
|
-
end
|
28
|
-
|
29
23
|
# An email was generated.
|
30
24
|
def process(event)
|
31
25
|
debug do
|
@@ -13,9 +13,14 @@ module ActionMailer
|
|
13
13
|
|
14
14
|
rescue_from StandardError, with: :handle_exception_with_mailer_class
|
15
15
|
|
16
|
-
def perform(mailer, mail_method, delivery_method, args:, params: nil)
|
16
|
+
def perform(mailer, mail_method, delivery_method, args:, kwargs: nil, params: nil)
|
17
17
|
mailer_class = params ? mailer.constantize.with(params) : mailer.constantize
|
18
|
-
|
18
|
+
message = if kwargs
|
19
|
+
mailer_class.public_send(mail_method, *args, **kwargs)
|
20
|
+
else
|
21
|
+
mailer_class.public_send(mail_method, *args)
|
22
|
+
end
|
23
|
+
message.send(delivery_method)
|
19
24
|
end
|
20
25
|
|
21
26
|
private
|
@@ -23,6 +23,7 @@ module ActionMailer
|
|
23
23
|
@processed_mailer = nil
|
24
24
|
@mail_message = nil
|
25
25
|
end
|
26
|
+
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
|
26
27
|
|
27
28
|
# Method calls are delegated to the Mail::Message that's ready to deliver.
|
28
29
|
def __getobj__ #:nodoc:
|
@@ -52,12 +53,14 @@ module ActionMailer
|
|
52
53
|
# Notifier.welcome(User.first).deliver_later!
|
53
54
|
# Notifier.welcome(User.first).deliver_later!(wait: 1.hour)
|
54
55
|
# Notifier.welcome(User.first).deliver_later!(wait_until: 10.hours.from_now)
|
56
|
+
# Notifier.welcome(User.first).deliver_later!(priority: 10)
|
55
57
|
#
|
56
58
|
# Options:
|
57
59
|
#
|
58
60
|
# * <tt>:wait</tt> - Enqueue the email to be delivered with a delay
|
59
61
|
# * <tt>:wait_until</tt> - Enqueue the email to be delivered at (after) a specific date / time
|
60
62
|
# * <tt>:queue</tt> - Enqueue the email on the specified queue
|
63
|
+
# * <tt>:priority</tt> - Enqueues the email with the specified priority
|
61
64
|
#
|
62
65
|
# By default, the email will be enqueued using <tt>ActionMailer::DeliveryJob</tt>. Each
|
63
66
|
# <tt>ActionMailer::Base</tt> class can specify the job to use by setting the class variable
|
@@ -76,12 +79,14 @@ module ActionMailer
|
|
76
79
|
# Notifier.welcome(User.first).deliver_later
|
77
80
|
# Notifier.welcome(User.first).deliver_later(wait: 1.hour)
|
78
81
|
# Notifier.welcome(User.first).deliver_later(wait_until: 10.hours.from_now)
|
82
|
+
# Notifier.welcome(User.first).deliver_later(priority: 10)
|
79
83
|
#
|
80
84
|
# Options:
|
81
85
|
#
|
82
86
|
# * <tt>:wait</tt> - Enqueue the email to be delivered with a delay.
|
83
87
|
# * <tt>:wait_until</tt> - Enqueue the email to be delivered at (after) a specific date / time.
|
84
88
|
# * <tt>:queue</tt> - Enqueue the email on the specified queue.
|
89
|
+
# * <tt>:priority</tt> - Enqueues the email with the specified priority
|
85
90
|
#
|
86
91
|
# By default, the email will be enqueued using <tt>ActionMailer::DeliveryJob</tt>. Each
|
87
92
|
# <tt>ActionMailer::Base</tt> class can specify the job to use by setting the class variable
|
@@ -136,16 +141,37 @@ module ActionMailer
|
|
136
141
|
"method*, or 3. use a custom Active Job instead of #deliver_later."
|
137
142
|
else
|
138
143
|
job = @mailer_class.delivery_job
|
139
|
-
|
140
|
-
job
|
144
|
+
|
145
|
+
if use_new_args?(job)
|
146
|
+
job.set(options).perform_later(
|
147
|
+
@mailer_class.name, @action.to_s, delivery_method.to_s, args: @args)
|
148
|
+
elsif job <= DeliveryJob
|
149
|
+
job.set(options).perform_later(
|
150
|
+
@mailer_class.name, @action.to_s, delivery_method.to_s, *@args)
|
151
|
+
else
|
152
|
+
ActiveSupport::Deprecation.warn(<<~EOM)
|
153
|
+
In Rails 6.2, Action Mailer will pass the mail arguments inside the `:args` keyword argument.
|
154
|
+
The `perform` method of the #{job} needs to change and forward the mail arguments
|
155
|
+
from the `args` keyword argument.
|
156
|
+
|
157
|
+
The `perform` method should now look like:
|
158
|
+
|
159
|
+
`def perform(mailer, mail_method, delivery, args:)`
|
160
|
+
EOM
|
161
|
+
|
162
|
+
job.set(options).perform_later(
|
163
|
+
@mailer_class.name, @action.to_s, delivery_method.to_s, *@args)
|
164
|
+
end
|
141
165
|
end
|
142
166
|
end
|
143
167
|
|
144
|
-
def
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
168
|
+
def use_new_args?(job)
|
169
|
+
parameters = job.public_instance_method(:perform).parameters
|
170
|
+
|
171
|
+
parameters.find do |key, name|
|
172
|
+
return true if key == :keyreq && name == :args
|
173
|
+
|
174
|
+
key == :keyrest
|
149
175
|
end
|
150
176
|
end
|
151
177
|
end
|
@@ -115,6 +115,7 @@ module ActionMailer
|
|
115
115
|
super
|
116
116
|
end
|
117
117
|
end
|
118
|
+
ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
|
118
119
|
|
119
120
|
def respond_to_missing?(method, include_all = false)
|
120
121
|
@mailer.respond_to?(method, include_all)
|
@@ -125,6 +126,7 @@ module ActionMailer
|
|
125
126
|
def perform(mailer, mail_method, delivery_method, params, *args)
|
126
127
|
mailer.constantize.with(params).public_send(mail_method, *args).send(delivery_method)
|
127
128
|
end
|
129
|
+
ruby2_keywords(:perform) if respond_to?(:ruby2_keywords, true)
|
128
130
|
end
|
129
131
|
|
130
132
|
class MessageDelivery < ActionMailer::MessageDelivery # :nodoc:
|
@@ -132,6 +134,7 @@ module ActionMailer
|
|
132
134
|
super(mailer_class, action, *args)
|
133
135
|
@params = params
|
134
136
|
end
|
137
|
+
ruby2_keywords(:initialize) if respond_to?(:ruby2_keywords, true)
|
135
138
|
|
136
139
|
private
|
137
140
|
def processed_mailer
|
@@ -145,9 +148,15 @@ module ActionMailer
|
|
145
148
|
if processed?
|
146
149
|
super
|
147
150
|
else
|
148
|
-
job
|
149
|
-
|
150
|
-
job
|
151
|
+
job = delivery_job_class
|
152
|
+
|
153
|
+
if job <= MailDeliveryJob
|
154
|
+
job.set(options).perform_later(
|
155
|
+
@mailer_class.name, @action.to_s, delivery_method.to_s, params: @params, args: @args)
|
156
|
+
else
|
157
|
+
job.set(options).perform_later(
|
158
|
+
@mailer_class.name, @action.to_s, delivery_method.to_s, @params, *@args)
|
159
|
+
end
|
151
160
|
end
|
152
161
|
end
|
153
162
|
|
@@ -158,14 +167,6 @@ module ActionMailer
|
|
158
167
|
Parameterized::DeliveryJob
|
159
168
|
end
|
160
169
|
end
|
161
|
-
|
162
|
-
def arguments_for(delivery_job, delivery_method)
|
163
|
-
if delivery_job <= MailDeliveryJob
|
164
|
-
[@mailer_class.name, @action.to_s, delivery_method.to_s, params: @params, args: @args]
|
165
|
-
else
|
166
|
-
[@mailer_class.name, @action.to_s, delivery_method.to_s, @params, *@args]
|
167
|
-
end
|
168
|
-
end
|
169
170
|
end
|
170
171
|
end
|
171
172
|
end
|
@@ -55,7 +55,6 @@ module ActionMailer
|
|
55
55
|
end
|
56
56
|
|
57
57
|
private
|
58
|
-
|
59
58
|
def interceptor_class_for(interceptor)
|
60
59
|
case interceptor
|
61
60
|
when String, Symbol
|
@@ -115,7 +114,7 @@ module ActionMailer
|
|
115
114
|
|
116
115
|
# Returns the underscored name of the mailer preview without the suffix.
|
117
116
|
def preview_name
|
118
|
-
name.
|
117
|
+
name.delete_suffix("Preview").underscore
|
119
118
|
end
|
120
119
|
|
121
120
|
private
|
@@ -18,11 +18,6 @@ module ActionMailer
|
|
18
18
|
paths = app.config.paths
|
19
19
|
options = app.config.action_mailer
|
20
20
|
|
21
|
-
if app.config.force_ssl
|
22
|
-
options.default_url_options ||= {}
|
23
|
-
options.default_url_options[:protocol] ||= "https"
|
24
|
-
end
|
25
|
-
|
26
21
|
options.assets_dir ||= paths["public"].first
|
27
22
|
options.javascripts_dir ||= paths["public/javascripts"].first
|
28
23
|
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
@@ -22,7 +22,6 @@ module ActionMailer
|
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
|
-
|
26
25
|
def clear_test_deliveries
|
27
26
|
if ActionMailer::Base.delivery_method == :test
|
28
27
|
ActionMailer::Base.deliveries.clear
|
@@ -76,7 +75,6 @@ module ActionMailer
|
|
76
75
|
end
|
77
76
|
|
78
77
|
private
|
79
|
-
|
80
78
|
def initialize_test_deliveries
|
81
79
|
set_delivery_method :test
|
82
80
|
@old_perform_deliveries = ActionMailer::Base.perform_deliveries
|
@@ -123,13 +123,13 @@ module ActionMailer
|
|
123
123
|
# ContactMailer.with(email: 'user@example.com').welcome.deliver_later
|
124
124
|
# end
|
125
125
|
# end
|
126
|
-
def assert_enqueued_email_with(mailer, method, args: nil, queue: "
|
126
|
+
def assert_enqueued_email_with(mailer, method, args: nil, queue: ActionMailer::Base.deliver_later_queue_name || "default", &block)
|
127
127
|
args = if args.is_a?(Hash)
|
128
128
|
[mailer.to_s, method.to_s, "deliver_now", params: args, args: []]
|
129
129
|
else
|
130
130
|
[mailer.to_s, method.to_s, "deliver_now", args: Array(args)]
|
131
131
|
end
|
132
|
-
assert_enqueued_with(job: mailer.delivery_job, args: args, queue: queue, &block)
|
132
|
+
assert_enqueued_with(job: mailer.delivery_job, args: args, queue: queue.to_s, &block)
|
133
133
|
end
|
134
134
|
|
135
135
|
# Asserts that no emails are enqueued for later delivery.
|
@@ -152,11 +152,11 @@ module ActionMailer
|
|
152
152
|
end
|
153
153
|
|
154
154
|
private
|
155
|
-
|
156
155
|
def delivery_job_filter(job)
|
157
156
|
job_class = job.is_a?(Hash) ? job.fetch(:job) : job.class
|
158
157
|
|
159
|
-
Base.descendants.map(&:delivery_job).include?(job_class)
|
158
|
+
Base.descendants.map(&:delivery_job).include?(job_class) ||
|
159
|
+
ActionMailer::Parameterized::DeliveryJob == job_class
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
data/lib/action_mailer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright (c) 2004-
|
4
|
+
# Copyright (c) 2004-2020 David Heinemeier Hansson
|
5
5
|
#
|
6
6
|
# Permission is hereby granted, free of charge, to any person obtaining
|
7
7
|
# a copy of this software and associated documentation files (the
|
@@ -67,4 +67,5 @@ autoload :Mime, "action_dispatch/http/mime_type"
|
|
67
67
|
ActiveSupport.on_load(:action_view) do
|
68
68
|
ActionView::Base.default_formats ||= Mime::SET.symbols
|
69
69
|
ActionView::Template::Types.delegate_to Mime
|
70
|
+
ActionView::LookupContext::DetailsKey.clear
|
70
71
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Description:
|
2
2
|
============
|
3
|
-
|
3
|
+
Generates a new mailer and its views. Passes the mailer name, either
|
4
4
|
CamelCased or under_scored, and an optional list of emails as arguments.
|
5
5
|
|
6
6
|
This generates a mailer class in app/mailers and invokes your template
|
@@ -8,10 +8,9 @@ Description:
|
|
8
8
|
|
9
9
|
Example:
|
10
10
|
========
|
11
|
-
rails generate mailer Notifications signup forgot_password invoice
|
11
|
+
bin/rails generate mailer Notifications signup forgot_password invoice
|
12
12
|
|
13
13
|
creates a Notifications mailer class, views, and test:
|
14
14
|
Mailer: app/mailers/notifications_mailer.rb
|
15
15
|
Views: app/views/notifications_mailer/signup.text.erb [...]
|
16
16
|
Test: test/mailers/notifications_mailer_test.rb
|
17
|
-
|
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.1.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.1.4
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: actionpack
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - '='
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.
|
33
|
+
version: 6.1.4
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - '='
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.
|
40
|
+
version: 6.1.4
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: actionview
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - '='
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 6.
|
47
|
+
version: 6.1.4
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - '='
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 6.
|
54
|
+
version: 6.1.4
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: activejob
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - '='
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 6.
|
61
|
+
version: 6.1.4
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - '='
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 6.
|
68
|
+
version: 6.1.4
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: mail
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,10 +137,10 @@ licenses:
|
|
123
137
|
- MIT
|
124
138
|
metadata:
|
125
139
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
126
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.
|
127
|
-
documentation_uri: https://api.rubyonrails.org/v6.
|
128
|
-
mailing_list_uri: https://
|
129
|
-
source_code_uri: https://github.com/rails/rails/tree/v6.
|
140
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.1.4/actionmailer/CHANGELOG.md
|
141
|
+
documentation_uri: https://api.rubyonrails.org/v6.1.4/
|
142
|
+
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
143
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.1.4/actionmailer
|
130
144
|
post_install_message:
|
131
145
|
rdoc_options: []
|
132
146
|
require_paths:
|
@@ -143,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
157
|
version: '0'
|
144
158
|
requirements:
|
145
159
|
- none
|
146
|
-
rubygems_version: 3.
|
160
|
+
rubygems_version: 3.1.2
|
147
161
|
signing_key:
|
148
162
|
specification_version: 4
|
149
163
|
summary: Email composition and delivery framework (part of Rails).
|