actionmailer 5.0.7.2 → 5.1.0.beta1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 8654112f1b184d1a2e795bc26c45b65967b133304a46730b2aab408942dc5617
4
- data.tar.gz: 506ad6d9768663adb6d5eeb8ba9d9a27f49198c45d7569702b95640008171af9
2
+ SHA1:
3
+ metadata.gz: 696c4f88a697ba0b0e13676985474e95a7223d3c
4
+ data.tar.gz: b96c279018c5233b31710b12789a436a6995f3bf
5
5
  SHA512:
6
- metadata.gz: 83e2e1be44ee1bed375c53ed7e8e6bc12bd2f6d9962dc26afdf854b8c85ba2d1b534b35bcd5fa8f9f7a9b516437ff9e0d6e32d4e838fa141d69212dc43153b79
7
- data.tar.gz: 62354bb387b14f5a0f50f8e698ac38546270de1b141e72cd7dec5dcb49e682490eaaa93df7136d47b0004c1b62ce5c80ad8635cb0a724ed25235dcb01c93b1d9
6
+ metadata.gz: 268f4af128811bec3ee5fcc8c3f524155db0d7263a1b7ba7f7a7f7fc09d623b886bcf9c5ca704aaa2ea39f905fcda273e67f1922cbd3bc58571a56a83c134ef5
7
+ data.tar.gz: bd1ea358a8ba9a02f7e13fc0154c9ce1415c83dbc21561e7bcf20f36bceec1d523cbaf93fe2d1ed42aced1fb3cc6478c632dbb932bd95b427f5d58999bbb0c54
@@ -1,200 +1,33 @@
1
- ## Rails 5.0.7.2 (March 11, 2019) ##
1
+ ## Rails 5.1.0.beta1 (February 23, 2017) ##
2
2
 
3
- * No changes.
4
-
5
-
6
- ## Rails 5.0.7.1 (November 27, 2018) ##
7
-
8
- * No changes.
9
-
10
-
11
- ## Rails 5.0.7 (March 29, 2018) ##
12
-
13
- * No changes.
14
-
15
-
16
- ## Rails 5.0.6 (September 07, 2017) ##
17
-
18
- * No changes.
19
-
20
-
21
- ## Rails 5.0.6.rc1 (August 24, 2017) ##
22
-
23
- * No changes.
24
-
25
-
26
- ## Rails 5.0.5 (July 31, 2017) ##
27
-
28
- * No changes.
29
-
30
-
31
- ## Rails 5.0.5.rc2 (July 25, 2017) ##
32
-
33
- * No changes.
34
-
35
-
36
- ## Rails 5.0.5.rc1 (July 19, 2017) ##
37
-
38
- * No changes.
39
-
40
-
41
- ## Rails 5.0.4 (June 19, 2017) ##
42
-
43
- * No changes.
44
-
45
-
46
- ## Rails 5.0.3 (May 12, 2017) ##
47
-
48
- * No changes.
49
-
50
-
51
- ## Rails 5.0.2 (March 01, 2017) ##
52
-
53
- * No changes.
54
-
55
-
56
- ## Rails 5.0.1 (December 21, 2016) ##
57
-
58
- * No changes.
59
-
60
-
61
- ## Rails 5.0.1.rc2 (December 10, 2016) ##
62
-
63
- * No changes.
64
-
65
-
66
- ## Rails 5.0.1.rc1 (December 01, 2016) ##
67
-
68
- * No changes.
69
-
70
-
71
- ## Rails 5.0.0 (June 30, 2016) ##
72
-
73
- * Exception handling: use `rescue_from` to handle exceptions raised by
74
- mailer actions, by message delivery, and by deferred delivery jobs.
75
-
76
- *Jeremy Daer*
77
-
78
- * Disallow calling `#deliver_later` after making local modifications to
79
- the message which would be lost when the delivery job is enqueued.
80
-
81
- Prevents a common, hard-to-find bug like:
82
-
83
- message = Notifier.welcome(user, foo)
84
- message.message_id = my_generated_message_id
85
- message.deliver_later
86
-
87
- The message_id is silently lost! *Only the mailer arguments are passed
88
- to the delivery job.*
89
-
90
- This raises an exception now. Make modifications to the message within
91
- the mailer method instead, or use a custom Active Job to manage delivery
92
- instead of using #deliver_later.
93
-
94
- *Jeremy Daer*
95
-
96
- * Removes `-t` from default Sendmail arguments to match the underlying
97
- `Mail::Sendmail` setting.
98
-
99
- *Clayton Liggitt*
100
-
101
- * Add support for fragment caching in Action Mailer views.
102
-
103
- *Stan Lo*
104
-
105
- * Reset `ActionMailer::Base.deliveries` after every test in
106
- `ActionDispatch::IntegrationTest`.
107
-
108
- *Yves Senn*
109
-
110
- * `config.action_mailer.default_url_options[:protocol]` is now set to `https` if `config.force_ssl` is set to `true`.
111
-
112
- *Andrew Kampjes*
113
-
114
- * Add `config.action_mailer.deliver_later_queue_name` configuration to set the
115
- mailer queue name.
116
-
117
- *Chris McGrath*
118
-
119
- * `assert_emails` in block form, uses the given number as expected value.
120
- This makes the error message much easier to understand.
3
+ * Add `:args` to `process.action_mailer` event.
121
4
 
122
5
  *Yuji Yaginuma*
123
6
 
124
- * Add support for inline images in mailer previews by using an interceptor
125
- class to convert cid: urls in image src attributes to data urls.
126
-
127
- *Andrew White*
128
-
129
- * Mailer preview now uses `url_for` to fix links to emails for apps running on
130
- a subdirectory.
7
+ * Add parameterized invocation of mailers as a way to share before filters and defaults between actions.
8
+ See `ActionMailer::Parameterized` for a full example of the benefit.
131
9
 
132
- *Remo Mueller*
10
+ *DHH*
133
11
 
134
- * Mailer previews no longer crash when the `mail` method wasn't called
135
- (`NullMail`).
12
+ * Allow lambdas to be used as lazy defaults in addition to procs.
136
13
 
137
- Fixes #19849.
14
+ *DHH*
138
15
 
139
- *Yves Senn*
140
-
141
- * Make sure labels and values line up in mailer previews.
142
-
143
- *Yves Senn*
144
-
145
- * Add `assert_enqueued_emails` and `assert_no_enqueued_emails`.
16
+ * Mime type: allow to custom content type when setting body in headers
17
+ and attachments.
146
18
 
147
19
  Example:
148
20
 
149
21
  def test_emails
150
- assert_enqueued_emails 2 do
151
- ContactMailer.welcome.deliver_later
152
- ContactMailer.welcome.deliver_later
153
- end
22
+ attachments["invoice.pdf"] = "This is test File content"
23
+ mail(body: "Hello there", content_type: "text/html")
154
24
  end
155
25
 
156
- def test_no_emails
157
- assert_no_enqueued_emails do
158
- # No emails enqueued here
159
- end
160
- end
161
-
162
- *George Claghorn*
163
-
164
- * Add `_mailer` suffix to mailers created via generator, following the same
165
- naming convention used in controllers and jobs.
166
-
167
- *Carlos Souza*
168
-
169
- * Remove deprecated `*_path` helpers in email views.
170
-
171
- *Rafael Mendonça França*
172
-
173
- * Remove deprecated `deliver` and `deliver!` methods.
174
-
175
- *claudiob*
26
+ *Minh Quy*
176
27
 
177
- * Template lookup now respects default locale and I18n fallbacks.
178
-
179
- Given the following templates:
180
-
181
- mailer/demo.html.erb
182
- mailer/demo.en.html.erb
183
- mailer/demo.pt.html.erb
184
-
185
- Before this change, for a locale that doesn't have its associated file, the
186
- `mailer/demo.html.erb` would be rendered even if `en` was the default locale.
187
-
188
- Now `mailer/demo.en.html.erb` has precedence over the file without locale.
189
-
190
- Also, it is possible to give a fallback.
191
-
192
- mailer/demo.pt.html.erb
193
- mailer/demo.pt-BR.html.erb
194
-
195
- So if the locale is `pt-PT`, `mailer/demo.pt.html.erb` will be rendered given
196
- the right I18n fallback configuration.
28
+ * Exception handling: use `rescue_from` to handle exceptions raised by
29
+ mailer actions, by message delivery, and by deferred delivery jobs.
197
30
 
198
- *Rafael Mendonça França*
31
+ *Jeremy Daer*
199
32
 
200
- Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionmailer/CHANGELOG.md) for previous changes.
33
+ Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/actionmailer/CHANGELOG.md) for previous changes.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2016 David Heinemeier Hansson
1
+ Copyright (c) 2004-2017 David Heinemeier Hansson
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -150,7 +150,7 @@ The latest version of Action Mailer can be installed with RubyGems:
150
150
 
151
151
  Source code can be downloaded as part of the Rails project on GitHub
152
152
 
153
- * https://github.com/rails/rails/tree/5-0-stable/actionmailer
153
+ * https://github.com/rails/rails/tree/master/actionmailer
154
154
 
155
155
 
156
156
  == License
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2004-2016 David Heinemeier Hansson
2
+ # Copyright (c) 2004-2017 David Heinemeier Hansson
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -21,16 +21,15 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
 
24
- require 'abstract_controller'
25
- require 'action_mailer/version'
24
+ require "abstract_controller"
25
+ require "action_mailer/version"
26
26
 
27
27
  # Common Active Support usage in Action Mailer
28
- require 'active_support'
29
- require 'active_support/rails'
30
- require 'active_support/core_ext/class'
31
- require 'active_support/core_ext/module/attr_internal'
32
- require 'active_support/core_ext/string/inflections'
33
- require 'active_support/lazy_load_hooks'
28
+ require "active_support/rails"
29
+ require "active_support/core_ext/class"
30
+ require "active_support/core_ext/module/attr_internal"
31
+ require "active_support/core_ext/string/inflections"
32
+ require "active_support/lazy_load_hooks"
34
33
 
35
34
  module ActionMailer
36
35
  extend ::ActiveSupport::Autoload
@@ -43,15 +42,16 @@ module ActionMailer
43
42
  autoload :DeliveryMethods
44
43
  autoload :InlinePreviewInterceptor
45
44
  autoload :MailHelper
45
+ autoload :Parameterized
46
46
  autoload :Preview
47
- autoload :Previews, 'action_mailer/preview'
47
+ autoload :Previews, "action_mailer/preview"
48
48
  autoload :TestCase
49
49
  autoload :TestHelper
50
50
  autoload :MessageDelivery
51
51
  autoload :DeliveryJob
52
52
  end
53
53
 
54
- autoload :Mime, 'action_dispatch/http/mime_type'
54
+ autoload :Mime, "action_dispatch/http/mime_type"
55
55
 
56
56
  ActiveSupport.on_load(:action_view) do
57
57
  ActionView::Base.default_formats ||= Mime::SET.symbols
@@ -1,11 +1,11 @@
1
- require 'mail'
2
- require 'action_mailer/collector'
3
- require 'active_support/core_ext/string/inflections'
4
- require 'active_support/core_ext/hash/except'
5
- require 'active_support/core_ext/module/anonymous'
1
+ require "mail"
2
+ require "action_mailer/collector"
3
+ require "active_support/core_ext/string/inflections"
4
+ require "active_support/core_ext/hash/except"
5
+ require "active_support/core_ext/module/anonymous"
6
6
 
7
- require 'action_mailer/log_subscriber'
8
- require 'action_mailer/rescuable'
7
+ require "action_mailer/log_subscriber"
8
+ require "action_mailer/rescuable"
9
9
 
10
10
  module ActionMailer
11
11
  # Action Mailer allows you to send email from your application using a mailer model and views.
@@ -208,6 +208,19 @@ module ActionMailer
208
208
  # end
209
209
  # end
210
210
  #
211
+ # You can also send attachments with html template, in this case you need to add body, attachments,
212
+ # and custom content type like this:
213
+ #
214
+ # class NotifierMailer < ApplicationMailer
215
+ # def welcome(recipient)
216
+ # attachments["free_book.pdf"] = File.read("path/to/file.pdf")
217
+ # mail(to: recipient,
218
+ # subject: "New account information",
219
+ # content_type: "text/html",
220
+ # body: "<html><body>Hello there</body></html>")
221
+ # end
222
+ # end
223
+ #
211
224
  # = Inline Attachments
212
225
  #
213
226
  # You can also specify that a file should be displayed inline with other HTML. This is useful
@@ -275,20 +288,19 @@ module ActionMailer
275
288
  # content_description: 'This is a description'
276
289
  # end
277
290
  #
278
- # Finally, Action Mailer also supports passing <tt>Proc</tt> objects into the default hash, so you
279
- # can define methods that evaluate as the message is being generated:
291
+ # Finally, Action Mailer also supports passing <tt>Proc</tt> and <tt>Lambda</tt> objects into the default hash,
292
+ # so you can define methods that evaluate as the message is being generated:
280
293
  #
281
294
  # class NotifierMailer < ApplicationMailer
282
- # default 'X-Special-Header' => Proc.new { my_method }
295
+ # default 'X-Special-Header' => Proc.new { my_method }, to: -> { @inviter.email_address }
283
296
  #
284
297
  # private
285
- #
286
298
  # def my_method
287
299
  # 'some complex call'
288
300
  # end
289
301
  # end
290
302
  #
291
- # Note that the proc is evaluated right at the start of the mail message generation, so if you
303
+ # Note that the proc/lambda is evaluated right at the start of the mail message generation, so if you
292
304
  # set something in the default hash using a proc, and then set the same thing inside of your
293
305
  # mailer method, it will get overwritten by the mailer method.
294
306
  #
@@ -311,7 +323,6 @@ module ActionMailer
311
323
  # end
312
324
  #
313
325
  # private
314
- #
315
326
  # def add_inline_attachment!
316
327
  # attachments.inline["footer.jpg"] = File.read('/path/to/filename.jpg')
317
328
  # end
@@ -390,9 +401,9 @@ module ActionMailer
390
401
  # to use it. Defaults to <tt>true</tt>.
391
402
  # * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is
392
403
  # really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name
393
- # of an OpenSSL verify constant (<tt>'none'</tt>, <tt>'peer'</tt>, <tt>'client_once'</tt>,
394
- # <tt>'fail_if_no_peer_cert'</tt>) or directly the constant (<tt>OpenSSL::SSL::VERIFY_NONE</tt>,
395
- # <tt>OpenSSL::SSL::VERIFY_PEER</tt>, ...).
404
+ # of an OpenSSL verify constant (<tt>'none'</tt> or <tt>'peer'</tt>) or directly the constant
405
+ # (<tt>OpenSSL::SSL::VERIFY_NONE</tt> or <tt>OpenSSL::SSL::VERIFY_PEER</tt>).
406
+ # <tt>:ssl/:tls</tt> Enables the SMTP connection to use SMTP/TLS (SMTPS: SMTP over direct TLS connection)
396
407
  #
397
408
  # * <tt>sendmail_settings</tt> - Allows you to override options for the <tt>:sendmail</tt> delivery method.
398
409
  # * <tt>:location</tt> - The location of the sendmail executable. Defaults to <tt>/usr/sbin/sendmail</tt>.
@@ -417,10 +428,11 @@ module ActionMailer
417
428
  # * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with
418
429
  # <tt>delivery_method :test</tt>. Most useful for unit and functional testing.
419
430
  #
420
- # * <tt>deliver_later_queue_name</tt> - The name of the queue used with <tt>deliver_later</tt>.
431
+ # * <tt>deliver_later_queue_name</tt> - The name of the queue used with <tt>deliver_later</tt>. Defaults to +mailers+.
421
432
  class Base < AbstractController::Base
422
433
  include DeliveryMethods
423
434
  include Rescuable
435
+ include Parameterized
424
436
  include Previews
425
437
 
426
438
  abstract!
@@ -487,7 +499,7 @@ module ActionMailer
487
499
  end
488
500
  private :observer_class_for
489
501
 
490
- # Returns the name of current mailer. This method is also being used as a path for a view lookup.
502
+ # Returns the name of the current mailer. This method is also being used as a path for a view lookup.
491
503
  # If this is an anonymous mailer, this method will return +anonymous+ instead.
492
504
  def mailer_name
493
505
  @mailer_name ||= anonymous? ? "anonymous" : name.underscore
@@ -544,9 +556,9 @@ module ActionMailer
544
556
  end
545
557
  end
546
558
 
547
- protected
559
+ private
548
560
 
549
- def set_payload_for_mail(payload, mail) #:nodoc:
561
+ def set_payload_for_mail(payload, mail)
550
562
  payload[:mailer] = name
551
563
  payload[:message_id] = mail.message_id
552
564
  payload[:subject] = mail.subject
@@ -558,7 +570,7 @@ module ActionMailer
558
570
  payload[:mail] = mail.encoded
559
571
  end
560
572
 
561
- def method_missing(method_name, *args) # :nodoc:
573
+ def method_missing(method_name, *args)
562
574
  if action_methods.include?(method_name.to_s)
563
575
  MessageDelivery.new(self, method_name, *args)
564
576
  else
@@ -566,10 +578,8 @@ module ActionMailer
566
578
  end
567
579
  end
568
580
 
569
- private
570
-
571
- def respond_to_missing?(method, include_all = false) #:nodoc:
572
- action_methods.include?(method.to_s)
581
+ def respond_to_missing?(method, include_all = false)
582
+ action_methods.include?(method.to_s) || super
573
583
  end
574
584
  end
575
585
 
@@ -588,7 +598,8 @@ module ActionMailer
588
598
  def process(method_name, *args) #:nodoc:
589
599
  payload = {
590
600
  mailer: self.class.name,
591
- action: method_name
601
+ action: method_name,
602
+ args: args
592
603
  }
593
604
 
594
605
  ActiveSupport::Notifications.instrument("process.action_mailer", payload) do
@@ -598,10 +609,10 @@ module ActionMailer
598
609
  end
599
610
 
600
611
  class NullMail #:nodoc:
601
- def body; '' end
612
+ def body; "" end
602
613
  def header; {} end
603
614
 
604
- def respond_to?(string, include_all=false)
615
+ def respond_to?(string, include_all = false)
605
616
  true
606
617
  end
607
618
 
@@ -830,138 +841,140 @@ module ActionMailer
830
841
  message
831
842
  end
832
843
 
833
- protected
834
-
835
- # Used by #mail to set the content type of the message.
836
- #
837
- # It will use the given +user_content_type+, or multipart if the mail
838
- # message has any attachments. If the attachments are inline, the content
839
- # type will be "multipart/related", otherwise "multipart/mixed".
840
- #
841
- # If there is no content type passed in via headers, and there are no
842
- # attachments, or the message is multipart, then the default content type is
843
- # used.
844
- def set_content_type(m, user_content_type, class_default)
845
- params = m.content_type_parameters || {}
846
- case
847
- when user_content_type.present?
848
- user_content_type
849
- when m.has_attachments?
850
- if m.attachments.detect(&:inline?)
851
- ["multipart", "related", params]
844
+ private
845
+
846
+ # Used by #mail to set the content type of the message.
847
+ #
848
+ # It will use the given +user_content_type+, or multipart if the mail
849
+ # message has any attachments. If the attachments are inline, the content
850
+ # type will be "multipart/related", otherwise "multipart/mixed".
851
+ #
852
+ # If there is no content type passed in via headers, and there are no
853
+ # attachments, or the message is multipart, then the default content type is
854
+ # used.
855
+ def set_content_type(m, user_content_type, class_default) # :doc:
856
+ params = m.content_type_parameters || {}
857
+ case
858
+ when user_content_type.present?
859
+ user_content_type
860
+ when m.has_attachments?
861
+ if m.attachments.detect(&:inline?)
862
+ ["multipart", "related", params]
863
+ else
864
+ ["multipart", "mixed", params]
865
+ end
866
+ when m.multipart?
867
+ ["multipart", "alternative", params]
852
868
  else
853
- ["multipart", "mixed", params]
869
+ m.content_type || class_default
854
870
  end
855
- when m.multipart?
856
- ["multipart", "alternative", params]
857
- else
858
- m.content_type || class_default
859
871
  end
860
- end
861
872
 
862
- # Translates the +subject+ using Rails I18n class under <tt>[mailer_scope, action_name]</tt> scope.
863
- # If it does not find a translation for the +subject+ under the specified scope it will default to a
864
- # humanized version of the <tt>action_name</tt>.
865
- # If the subject has interpolations, you can pass them through the +interpolations+ parameter.
866
- def default_i18n_subject(interpolations = {})
867
- mailer_scope = self.class.mailer_name.tr('/', '.')
868
- I18n.t(:subject, interpolations.merge(scope: [mailer_scope, action_name], default: action_name.humanize))
869
- end
873
+ # Translates the +subject+ using Rails I18n class under <tt>[mailer_scope, action_name]</tt> scope.
874
+ # If it does not find a translation for the +subject+ under the specified scope it will default to a
875
+ # humanized version of the <tt>action_name</tt>.
876
+ # If the subject has interpolations, you can pass them through the +interpolations+ parameter.
877
+ def default_i18n_subject(interpolations = {}) # :doc:
878
+ mailer_scope = self.class.mailer_name.tr("/", ".")
879
+ I18n.t(:subject, interpolations.merge(scope: [mailer_scope, action_name], default: action_name.humanize))
880
+ end
870
881
 
871
- # Emails do not support relative path links.
872
- def self.supports_path?
873
- false
874
- end
882
+ # Emails do not support relative path links.
883
+ def self.supports_path? # :doc:
884
+ false
885
+ end
875
886
 
876
- private
887
+ def apply_defaults(headers)
888
+ default_values = self.class.default.map do |key, value|
889
+ [
890
+ key,
891
+ value.is_a?(Proc) ? instance_exec(&value) : value
892
+ ]
893
+ end.to_h
894
+
895
+ headers_with_defaults = headers.reverse_merge(default_values)
896
+ headers_with_defaults[:subject] ||= default_i18n_subject
897
+ headers_with_defaults
898
+ end
877
899
 
878
- def apply_defaults(headers)
879
- default_values = self.class.default.map do |key, value|
880
- [
881
- key,
882
- value.is_a?(Proc) ? instance_eval(&value) : value
883
- ]
884
- end.to_h
885
-
886
- headers_with_defaults = headers.reverse_merge(default_values)
887
- headers_with_defaults[:subject] ||= default_i18n_subject
888
- headers_with_defaults
889
- end
900
+ def assign_headers_to_message(message, headers)
901
+ assignable = headers.except(:parts_order, :content_type, :body, :template_name,
902
+ :template_path, :delivery_method, :delivery_method_options)
903
+ assignable.each { |k, v| message[k] = v }
904
+ end
890
905
 
891
- def assign_headers_to_message(message, headers)
892
- assignable = headers.except(:parts_order, :content_type, :body, :template_name,
893
- :template_path, :delivery_method, :delivery_method_options)
894
- assignable.each { |k, v| message[k] = v }
895
- end
906
+ def collect_responses(headers)
907
+ if block_given?
908
+ collector = ActionMailer::Collector.new(lookup_context) { render(action_name) }
909
+ yield(collector)
910
+ collector.responses
911
+ elsif headers[:body]
912
+ collect_responses_from_text(headers)
913
+ else
914
+ collect_responses_from_templates(headers)
915
+ end
916
+ end
896
917
 
897
- def collect_responses(headers)
898
- if block_given?
899
- collector = ActionMailer::Collector.new(lookup_context) { render(action_name) }
900
- yield(collector)
901
- collector.responses
902
- elsif headers[:body]
918
+ def collect_responses_from_text(headers)
903
919
  [{
904
920
  body: headers.delete(:body),
905
- content_type: self.class.default[:content_type] || "text/plain"
921
+ content_type: headers[:content_type] || "text/plain"
906
922
  }]
907
- else
908
- collect_responses_from_templates(headers)
909
923
  end
910
- end
911
924
 
912
- def collect_responses_from_templates(headers)
913
- templates_path = headers[:template_path] || self.class.mailer_name
914
- templates_name = headers[:template_name] || action_name
925
+ def collect_responses_from_templates(headers)
926
+ templates_path = headers[:template_path] || self.class.mailer_name
927
+ templates_name = headers[:template_name] || action_name
915
928
 
916
- each_template(Array(templates_path), templates_name).map do |template|
917
- self.formats = template.formats
918
- {
919
- body: render(template: template),
920
- content_type: template.type.to_s
921
- }
929
+ each_template(Array(templates_path), templates_name).map do |template|
930
+ self.formats = template.formats
931
+ {
932
+ body: render(template: template),
933
+ content_type: template.type.to_s
934
+ }
935
+ end
922
936
  end
923
- end
924
937
 
925
- def each_template(paths, name, &block)
926
- templates = lookup_context.find_all(name, paths)
927
- if templates.empty?
928
- raise ActionView::MissingTemplate.new(paths, name, paths, false, 'mailer')
929
- else
930
- templates.uniq(&:formats).each(&block)
938
+ def each_template(paths, name, &block)
939
+ templates = lookup_context.find_all(name, paths)
940
+ if templates.empty?
941
+ raise ActionView::MissingTemplate.new(paths, name, paths, false, "mailer")
942
+ else
943
+ templates.uniq(&:formats).each(&block)
944
+ end
931
945
  end
932
- end
933
946
 
934
- def create_parts_from_responses(m, responses)
935
- if responses.size == 1 && !m.has_attachments?
936
- responses[0].each { |k,v| m[k] = v }
937
- elsif responses.size > 1 && m.has_attachments?
938
- container = Mail::Part.new
939
- container.content_type = "multipart/alternative"
940
- responses.each { |r| insert_part(container, r, m.charset) }
941
- m.add_part(container)
942
- else
943
- responses.each { |r| insert_part(m, r, m.charset) }
947
+ def create_parts_from_responses(m, responses)
948
+ if responses.size == 1 && !m.has_attachments?
949
+ responses[0].each { |k, v| m[k] = v }
950
+ elsif responses.size > 1 && m.has_attachments?
951
+ container = Mail::Part.new
952
+ container.content_type = "multipart/alternative"
953
+ responses.each { |r| insert_part(container, r, m.charset) }
954
+ m.add_part(container)
955
+ else
956
+ responses.each { |r| insert_part(m, r, m.charset) }
957
+ end
944
958
  end
945
- end
946
959
 
947
- def insert_part(container, response, charset)
948
- response[:charset] ||= charset
949
- part = Mail::Part.new(response)
950
- container.add_part(part)
951
- end
960
+ def insert_part(container, response, charset)
961
+ response[:charset] ||= charset
962
+ part = Mail::Part.new(response)
963
+ container.add_part(part)
964
+ end
952
965
 
953
- # This and #instrument_name is for caching instrument
954
- def instrument_payload(key)
955
- {
956
- mailer: mailer_name,
957
- key: key
958
- }
959
- end
966
+ # This and #instrument_name is for caching instrument
967
+ def instrument_payload(key)
968
+ {
969
+ mailer: mailer_name,
970
+ key: key
971
+ }
972
+ end
960
973
 
961
- def instrument_name
962
- "action_mailer"
963
- end
974
+ def instrument_name
975
+ "action_mailer".freeze
976
+ end
964
977
 
965
- ActiveSupport.run_load_hooks(:action_mailer, self)
978
+ ActiveSupport.run_load_hooks(:action_mailer, self)
966
979
  end
967
980
  end