@@ -91,7 +91,7 @@ def arguments_match?(job)
91
91
92
92
def process_arguments ( job , given_mail_args )
93
93
# Old matcher behavior working with all builtin classes but ActionMailer::MailDeliveryJob
94
- return given_mail_args unless defined? ( ActionMailer :: MailDeliveryJob ) && job [ :job ] <= ActionMailer :: MailDeliveryJob
94
+ return given_mail_args if use_given_mail_args? ( job )
95
95
96
96
# If matching args starts with a hash and job instance has params match with them
97
97
if given_mail_args . first . is_a? ( Hash ) && job [ :args ] [ 3 ] [ 'params' ] . present?
@@ -101,6 +101,19 @@ def process_arguments(job, given_mail_args)
101
101
end
102
102
end
103
103
104
+ def use_given_mail_args? ( job )
105
+ return false if rails_6_1_and_ruby_3_1?
106
+
107
+ !( defined? ( ActionMailer ::MailDeliveryJob ) && job [ :job ] <= ActionMailer ::MailDeliveryJob )
108
+ end
109
+
110
+ def rails_6_1_and_ruby_3_1?
111
+ return false unless RUBY_VERSION >= "3.1"
112
+ return false unless ::Rails ::VERSION ::STRING >= '6.1'
113
+
114
+ ::Rails ::VERSION ::STRING < '7'
115
+ end
116
+
104
117
def base_mailer_args
105
118
[ mailer_class_name , @method_name . to_s , MAILER_JOB_METHOD ]
106
119
end
@@ -143,13 +156,20 @@ def mail_job_message(job)
143
156
mailer_args = deserialize_arguments ( job ) [ 3 ..-1 ]
144
157
mailer_args = mailer_args . first [ :args ] if unified_mail? ( job )
145
158
msg_parts = [ ]
146
- msg_parts << "with #{ mailer_args } " if mailer_args . any?
159
+ display_args = display_mailer_args ( mailer_args )
160
+ msg_parts << "with #{ display_args } " if display_args . any?
147
161
msg_parts << "on queue #{ job [ :queue ] } " if job [ :queue ] && job [ :queue ] != 'mailers'
148
162
msg_parts << "at #{ Time . at ( job [ :at ] ) } " if job [ :at ]
149
163
150
164
"#{ mailer_method } #{ msg_parts . join ( ', ' ) } " . strip
151
165
end
152
166
167
+ def display_mailer_args ( mailer_args )
168
+ return mailer_args unless mailer_args . first . is_a? ( Hash ) && mailer_args . first . key? ( :args )
169
+
170
+ mailer_args . first [ :args ]
171
+ end
172
+
153
173
def legacy_mail? ( job )
154
174
RSpec ::Rails ::FeatureCheck . has_action_mailer_legacy_delivery_job? && job [ :job ] <= ActionMailer ::DeliveryJob
155
175
end
0 commit comments