actionmailer 4.1.16 → 4.2.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 +4 -4
- data/CHANGELOG.md +20 -176
- data/README.rdoc +7 -3
- data/lib/action_mailer.rb +2 -1
- data/lib/action_mailer/base.rb +23 -15
- data/lib/action_mailer/delivery_job.rb +11 -0
- data/lib/action_mailer/gem_version.rb +3 -3
- data/lib/action_mailer/log_subscriber.rb +13 -10
- data/lib/action_mailer/mail_helper.rb +3 -3
- data/lib/action_mailer/message_delivery.rb +45 -0
- data/lib/action_mailer/preview.rb +12 -0
- data/lib/action_mailer/railtie.rb +10 -2
- data/lib/action_mailer/test_case.rb +19 -1
- data/lib/action_mailer/test_helper.rb +2 -0
- data/lib/action_mailer/version.rb +2 -1
- metadata +31 -10
- data/lib/action_mailer/inline_preview_interceptor.rb +0 -61
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b645b4249222f8f9158e506e7ce6f9896b94ffb1
|
4
|
+
data.tar.gz: c37159e974453b38edeb571c2a7856520c80bd40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7be91503097c551664c180a89064411f1a0e0caedcb57568b72a952dbb1ba416e1b0cdb6921caa23eda9cd7cf35cdb7838dfe22e8885805d7bfbe385afbb5e1
|
7
|
+
data.tar.gz: b5f6483b59c93b59c7f290ece2214e96def84c552255f5365b2cf5fe0a02eeb94ace98e024ec223e2f6aaa74dff81d62332dbf1fd85acb2f5cf6fffa23d0eebc
|
data/CHANGELOG.md
CHANGED
@@ -1,91 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
## Rails 4.1.15 (March 07, 2016) ##
|
7
|
-
|
8
|
-
* No changes.
|
9
|
-
|
10
|
-
|
11
|
-
## Rails 4.1.14.2 (February 26, 2016) ##
|
12
|
-
|
13
|
-
* No changes.
|
14
|
-
|
15
|
-
|
16
|
-
## Rails 4.1.14.1 (January 25, 2015) ##
|
17
|
-
|
18
|
-
* No changes.
|
19
|
-
|
20
|
-
|
21
|
-
## Rails 4.1.14 (November 12, 2015) ##
|
22
|
-
|
23
|
-
* No changes.
|
24
|
-
|
25
|
-
|
26
|
-
## Rails 4.1.14.rc1 (October 30, 2015) ##
|
27
|
-
|
28
|
-
* No changes.
|
29
|
-
|
30
|
-
|
31
|
-
## Rails 4.1.13 (August 24, 2015) ##
|
32
|
-
|
33
|
-
* No changes.
|
34
|
-
|
35
|
-
|
36
|
-
## Rails 4.1.12 (June 25, 2015) ##
|
37
|
-
|
38
|
-
* Mailer preview now uses `url_for` to fix links to emails for apps running on
|
39
|
-
a subdirectory.
|
40
|
-
|
41
|
-
*Remo Mueller*
|
42
|
-
|
43
|
-
* Mailer previews no longer crash when the `mail` method wasn't called
|
44
|
-
(`NullMail`).
|
45
|
-
|
46
|
-
Fixes #19849.
|
47
|
-
|
48
|
-
*Yves Senn*
|
49
|
-
|
50
|
-
* Make sure labels and values line up in mailer previews.
|
51
|
-
|
52
|
-
*Yves Senn*
|
53
|
-
|
54
|
-
|
55
|
-
## Rails 4.1.11 (June 16, 2015) ##
|
56
|
-
|
57
|
-
* No changes.
|
58
|
-
|
59
|
-
|
60
|
-
## Rails 4.1.10 (March 19, 2015) ##
|
61
|
-
|
62
|
-
* No changes.
|
63
|
-
|
64
|
-
|
65
|
-
## Rails 4.1.9 (January 6, 2015) ##
|
66
|
-
|
67
|
-
* No changes.
|
68
|
-
|
69
|
-
|
70
|
-
## Rails 4.1.8 (November 16, 2014) ##
|
71
|
-
|
72
|
-
* Attachments can be added while rendering the mail template.
|
73
|
-
|
74
|
-
Fixes #16974.
|
75
|
-
|
76
|
-
*Christian Felder*
|
77
|
-
|
78
|
-
## Rails 4.1.7.1 (November 19, 2014) ##
|
79
|
-
|
80
|
-
* No changes.
|
81
|
-
|
82
|
-
|
83
|
-
## Rails 4.1.7 (October 29, 2014) ##
|
84
|
-
|
85
|
-
* No changes.
|
86
|
-
|
87
|
-
|
88
|
-
## Rails 4.1.6 (September 11, 2014) ##
|
1
|
+
* Added #deliver_later in addition to #deliver, which will enqueue a job to render and
|
2
|
+
deliver the mail instead of delivering it right at that moment. The job is enqueued
|
3
|
+
using the new Active Job framework in Rails, and will use whatever queue is configured for Rails.
|
4
|
+
|
5
|
+
*DHH/Abdelkader Boudih/Cristian Bica*
|
89
6
|
|
90
7
|
* Make ActionMailer::Previews methods class methods. Previously they were
|
91
8
|
instance methods and ActionMailer tries to render a message when they
|
@@ -93,6 +10,12 @@
|
|
93
10
|
|
94
11
|
*Cristian Bica*
|
95
12
|
|
13
|
+
* Deprecate `*_path` helpers in email views. When used they generate
|
14
|
+
non-working links and are not the intention of most developers. Instead
|
15
|
+
we recommend to use `*_url` helper.
|
16
|
+
|
17
|
+
*Richard Schneeman*
|
18
|
+
|
96
19
|
* Raise an exception when attachments are added after `mail` was called.
|
97
20
|
This is a safeguard to prevent invalid emails.
|
98
21
|
|
@@ -100,99 +23,20 @@
|
|
100
23
|
|
101
24
|
*Yves Senn*
|
102
25
|
|
103
|
-
*
|
104
|
-
`config.action_mailer.preview_interceptors`.
|
105
|
-
|
106
|
-
See #15739.
|
107
|
-
|
108
|
-
*Yves Senn*
|
109
|
-
|
110
|
-
|
111
|
-
## Rails 4.1.5 (August 18, 2014) ##
|
112
|
-
|
113
|
-
* No changes.
|
114
|
-
|
115
|
-
|
116
|
-
## Rails 4.1.4 (July 2, 2014) ##
|
117
|
-
|
118
|
-
* No changes.
|
119
|
-
|
120
|
-
|
121
|
-
## Rails 4.1.3 (July 2, 2014) ##
|
122
|
-
|
123
|
-
* No changes.
|
124
|
-
|
125
|
-
|
126
|
-
## Rails 4.1.2 (June 26, 2014) ##
|
127
|
-
|
128
|
-
* No changes.
|
129
|
-
|
26
|
+
* Add `config.action_mailer.show_previews` configuration option.
|
130
27
|
|
131
|
-
|
28
|
+
This config option can be used to enable the mail preview in environments
|
29
|
+
other than development (such as staging).
|
132
30
|
|
133
|
-
|
31
|
+
Defaults to `true` in development and false elsewhere.
|
134
32
|
|
33
|
+
*Leonard Garvey*
|
135
34
|
|
136
|
-
|
137
|
-
|
138
|
-
* Support the use of underscored symbols when registering interceptors and
|
139
|
-
observers like we do elsewhere within Rails.
|
140
|
-
|
141
|
-
*Andrew White*
|
142
|
-
|
143
|
-
* Add the ability to intercept emails before previewing in a similar fashion
|
144
|
-
to how emails can be intercepted before delivery.
|
145
|
-
|
146
|
-
Fixes #13622.
|
147
|
-
|
148
|
-
Example:
|
149
|
-
|
150
|
-
class CSSInlineStyler
|
151
|
-
def self.previewing_email(message)
|
152
|
-
# inline CSS styles
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
ActionMailer::Base.register_preview_interceptor CSSInlineStyler
|
157
|
-
|
158
|
-
*Andrew White*
|
159
|
-
|
160
|
-
* Add mailer previews feature based on 37 Signals mail_view gem.
|
161
|
-
|
162
|
-
*Andrew White*
|
163
|
-
|
164
|
-
* Calling `mail()` without arguments serves as getter for the current mail
|
165
|
-
message and keeps previously set headers.
|
166
|
-
|
167
|
-
Fixes #13090.
|
168
|
-
|
169
|
-
Example:
|
170
|
-
|
171
|
-
class MailerWithCallback < ActionMailer::Base
|
172
|
-
after_action :a_callback
|
173
|
-
|
174
|
-
def welcome
|
175
|
-
mail subject: "subject", to: ["joe@example.com"]
|
176
|
-
end
|
35
|
+
* Allow preview interceptors to be registered through
|
36
|
+
`config.action_mailer.preview_interceptors`.
|
177
37
|
|
178
|
-
|
179
|
-
mail # => returns the current mail message
|
180
|
-
end
|
181
|
-
end
|
38
|
+
See #15739.
|
182
39
|
|
183
40
|
*Yves Senn*
|
184
41
|
|
185
|
-
|
186
|
-
generate a message is written to the log.
|
187
|
-
|
188
|
-
*Daniel Schierbeck*
|
189
|
-
|
190
|
-
* Invoke mailer defaults as procs only if they are procs, do not convert with
|
191
|
-
`to_proc`. That an object is convertible to a proc does not mean it's meant
|
192
|
-
to be always used as a proc.
|
193
|
-
|
194
|
-
Fixes #11533.
|
195
|
-
|
196
|
-
*Alex Tsukernik*
|
197
|
-
|
198
|
-
Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/actionmailer/CHANGELOG.md) for previous changes.
|
42
|
+
Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/actionmailer/CHANGELOG.md) for previous changes.
|
data/README.rdoc
CHANGED
@@ -102,7 +102,7 @@ Example:
|
|
102
102
|
)
|
103
103
|
|
104
104
|
if email.has_attachments?
|
105
|
-
email.attachments.each do |attachment|
|
105
|
+
email.attachments.each do |attachment|
|
106
106
|
page.attachments.create({
|
107
107
|
file: attachment, description: email.subject
|
108
108
|
})
|
@@ -140,7 +140,7 @@ The latest version of Action Mailer can be installed with RubyGems:
|
|
140
140
|
|
141
141
|
Source code can be downloaded as part of the Rails project on GitHub
|
142
142
|
|
143
|
-
* https://github.com/rails/rails/tree/
|
143
|
+
* https://github.com/rails/rails/tree/master/actionmailer
|
144
144
|
|
145
145
|
|
146
146
|
== License
|
@@ -156,7 +156,11 @@ API documentation is at
|
|
156
156
|
|
157
157
|
* http://api.rubyonrails.org
|
158
158
|
|
159
|
-
Bug reports
|
159
|
+
Bug reports can be filed for the Ruby on Rails project here:
|
160
160
|
|
161
161
|
* https://github.com/rails/rails/issues
|
162
162
|
|
163
|
+
Feature requests should be discussed on the rails-core mailing list here:
|
164
|
+
|
165
|
+
* https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
|
166
|
+
|
data/lib/action_mailer.rb
CHANGED
@@ -40,10 +40,11 @@ module ActionMailer
|
|
40
40
|
|
41
41
|
autoload :Base
|
42
42
|
autoload :DeliveryMethods
|
43
|
-
autoload :InlinePreviewInterceptor
|
44
43
|
autoload :MailHelper
|
45
44
|
autoload :Preview
|
46
45
|
autoload :Previews, 'action_mailer/preview'
|
47
46
|
autoload :TestCase
|
48
47
|
autoload :TestHelper
|
48
|
+
autoload :MessageDelivery
|
49
|
+
autoload :DeliveryJob
|
49
50
|
end
|
data/lib/action_mailer/base.rb
CHANGED
@@ -94,7 +94,7 @@ module ActionMailer
|
|
94
94
|
# Hi <%= @account.name %>,
|
95
95
|
# Thanks for joining our service! Please check back often.
|
96
96
|
#
|
97
|
-
# You can even use Action
|
97
|
+
# You can even use Action View helpers in these views. For example:
|
98
98
|
#
|
99
99
|
# You got a new note!
|
100
100
|
# <%= truncate(@note.body, length: 25) %>
|
@@ -154,7 +154,7 @@ module ActionMailer
|
|
154
154
|
# * signup_notification.text.erb
|
155
155
|
# * signup_notification.html.erb
|
156
156
|
# * signup_notification.xml.builder
|
157
|
-
# * signup_notification.
|
157
|
+
# * signup_notification.yml.erb
|
158
158
|
#
|
159
159
|
# Each would be rendered and added as a separate part to the message, with the corresponding content
|
160
160
|
# type. The content type for the entire message is automatically set to <tt>multipart/alternative</tt>,
|
@@ -301,12 +301,13 @@ module ActionMailer
|
|
301
301
|
# end
|
302
302
|
# end
|
303
303
|
#
|
304
|
-
# Callbacks in
|
305
|
-
# can define and configure
|
306
|
-
#
|
304
|
+
# Callbacks in Action Mailer are implemented using
|
305
|
+
# <tt>AbstractController::Callbacks</tt>, so you can define and configure
|
306
|
+
# callbacks in the same manner that you would use callbacks in classes that
|
307
|
+
# inherit from <tt>ActionController::Base</tt>.
|
307
308
|
#
|
308
309
|
# Note that unless you have a specific reason to do so, you should prefer using before_action
|
309
|
-
# rather than after_action in your
|
310
|
+
# rather than after_action in your Action Mailer classes so that headers are parsed properly.
|
310
311
|
#
|
311
312
|
# = Previewing emails
|
312
313
|
#
|
@@ -325,7 +326,7 @@ module ActionMailer
|
|
325
326
|
# directory can be configured using the <tt>preview_path</tt> option which has a default
|
326
327
|
# of <tt>test/mailers/previews</tt>:
|
327
328
|
#
|
328
|
-
#
|
329
|
+
# config.action_mailer.preview_path = "#{Rails.root}/lib/mailer_previews"
|
329
330
|
#
|
330
331
|
# An overview of all previews is accessible at <tt>http://localhost:3000/rails/mailers</tt>
|
331
332
|
# on a running development server instance.
|
@@ -368,8 +369,8 @@ module ActionMailer
|
|
368
369
|
# This is a symbol and one of <tt>:plain</tt> (will send the password in the clear), <tt>:login</tt> (will
|
369
370
|
# send password Base64 encoded) or <tt>:cram_md5</tt> (combines a Challenge/Response mechanism to exchange
|
370
371
|
# information and a cryptographic Message Digest 5 algorithm to hash important information)
|
371
|
-
# * <tt>:enable_starttls_auto</tt> -
|
372
|
-
#
|
372
|
+
# * <tt>:enable_starttls_auto</tt> - Detects if STARTTLS is enabled in your SMTP server and starts
|
373
|
+
# to use it. Defaults to <tt>true</tt>.
|
373
374
|
# * <tt>:openssl_verify_mode</tt> - When using TLS, you can set how OpenSSL checks the certificate. This is
|
374
375
|
# really useful if you need to validate a self-signed and/or a wildcard certificate. You can use the name
|
375
376
|
# of an OpenSSL verify constant (<tt>'none'</tt>, <tt>'peer'</tt>, <tt>'client_once'</tt>,
|
@@ -393,7 +394,7 @@ module ActionMailer
|
|
393
394
|
# implement for a custom delivery agent.
|
394
395
|
#
|
395
396
|
# * <tt>perform_deliveries</tt> - Determines whether emails are actually sent from Action Mailer when you
|
396
|
-
# call <tt>.deliver</tt> on an
|
397
|
+
# call <tt>.deliver</tt> on an email message or on an Action Mailer method. This is on by default but can
|
397
398
|
# be turned off to aid in functional testing.
|
398
399
|
#
|
399
400
|
# * <tt>deliveries</tt> - Keeps an array of all the emails sent out through the Action Mailer with
|
@@ -547,8 +548,8 @@ module ActionMailer
|
|
547
548
|
end
|
548
549
|
|
549
550
|
def method_missing(method_name, *args) # :nodoc:
|
550
|
-
if
|
551
|
-
new(method_name, *args)
|
551
|
+
if action_methods.include?(method_name.to_s)
|
552
|
+
MessageDelivery.new(self, method_name, *args)
|
552
553
|
else
|
553
554
|
super
|
554
555
|
end
|
@@ -584,7 +585,10 @@ module ActionMailer
|
|
584
585
|
|
585
586
|
class NullMail #:nodoc:
|
586
587
|
def body; '' end
|
587
|
-
|
588
|
+
|
589
|
+
def respond_to?(string, include_all=false)
|
590
|
+
true
|
591
|
+
end
|
588
592
|
|
589
593
|
def method_missing(*args)
|
590
594
|
nil
|
@@ -760,6 +764,7 @@ module ActionMailer
|
|
760
764
|
def mail(headers = {}, &block)
|
761
765
|
return @_message if @_mail_was_called && headers.blank? && !block
|
762
766
|
|
767
|
+
@_mail_was_called = true
|
763
768
|
m = @_message
|
764
769
|
|
765
770
|
# At the beginning, do not consider class default for content_type
|
@@ -787,8 +792,6 @@ module ActionMailer
|
|
787
792
|
|
788
793
|
# Render the templates and blocks
|
789
794
|
responses = collect_responses(headers, &block)
|
790
|
-
@_mail_was_called = true
|
791
|
-
|
792
795
|
create_parts_from_responses(m, responses)
|
793
796
|
|
794
797
|
# Setup content type, reapply charset and handle parts order
|
@@ -898,6 +901,11 @@ module ActionMailer
|
|
898
901
|
container.add_part(part)
|
899
902
|
end
|
900
903
|
|
904
|
+
# Emails do not support relative path links.
|
905
|
+
def self.supports_path?
|
906
|
+
false
|
907
|
+
end
|
908
|
+
|
901
909
|
ActiveSupport.run_load_hooks(:action_mailer, self)
|
902
910
|
end
|
903
911
|
end
|
@@ -6,24 +6,27 @@ module ActionMailer
|
|
6
6
|
class LogSubscriber < ActiveSupport::LogSubscriber
|
7
7
|
# An email was delivered.
|
8
8
|
def deliver(event)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
info do
|
10
|
+
recipients = Array(event.payload[:to]).join(', ')
|
11
|
+
"\nSent mail to #{recipients} (#{event.duration.round(1)}ms)"
|
12
|
+
end
|
13
|
+
|
14
|
+
debug { event.payload[:mail] }
|
13
15
|
end
|
14
16
|
|
15
17
|
# An email was received.
|
16
18
|
def receive(event)
|
17
|
-
|
18
|
-
|
19
|
-
debug(event.payload[:mail])
|
19
|
+
info { "\nReceived mail (#{event.duration.round(1)}ms)" }
|
20
|
+
debug { event.payload[:mail] }
|
20
21
|
end
|
21
22
|
|
22
23
|
# An email was generated.
|
23
24
|
def process(event)
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
debug do
|
26
|
+
mailer = event.payload[:mailer]
|
27
|
+
action = event.payload[:action]
|
28
|
+
"\n#{mailer}##{action}: processed outbound mail in #{event.duration.round(1)}ms"
|
29
|
+
end
|
27
30
|
end
|
28
31
|
|
29
32
|
# Use the logger configured for ActionMailer::Base
|
@@ -11,8 +11,8 @@ module ActionMailer
|
|
11
11
|
}.join("\n\n")
|
12
12
|
|
13
13
|
# Make list points stand on their own line
|
14
|
-
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) {
|
15
|
-
formatted.gsub!(/[ ]*([#]+) ([^#]*)/) {
|
14
|
+
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { " #{$1} #{$2.strip}\n" }
|
15
|
+
formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { " #{$1} #{$2.strip}\n" }
|
16
16
|
|
17
17
|
formatted
|
18
18
|
end
|
@@ -29,7 +29,7 @@ module ActionMailer
|
|
29
29
|
|
30
30
|
# Access the message attachments list.
|
31
31
|
def attachments
|
32
|
-
|
32
|
+
@_message.attachments
|
33
33
|
end
|
34
34
|
|
35
35
|
# Returns +text+ wrapped at +len+ columns and indented +indent+ spaces.
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
3
|
+
module ActionMailer
|
4
|
+
class MessageDelivery < Delegator
|
5
|
+
def initialize(mailer, mail_method, *args)
|
6
|
+
@mailer = mailer
|
7
|
+
@mail_method = mail_method
|
8
|
+
@args = args
|
9
|
+
end
|
10
|
+
|
11
|
+
def __getobj__
|
12
|
+
@obj ||= @mailer.send(:new, @mail_method, *@args).message
|
13
|
+
end
|
14
|
+
|
15
|
+
def __setobj__(obj)
|
16
|
+
@obj = obj
|
17
|
+
end
|
18
|
+
|
19
|
+
def message #:nodoc:
|
20
|
+
__getobj__
|
21
|
+
end
|
22
|
+
|
23
|
+
def deliver_later!(options={})
|
24
|
+
enqueue_delivery :deliver!, options
|
25
|
+
end
|
26
|
+
|
27
|
+
def deliver_later(options={})
|
28
|
+
enqueue_delivery :deliver, options
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def enqueue_delivery(delivery_method, options={})
|
33
|
+
args = @mailer.name, @mail_method.to_s, delivery_method.to_s, *@args
|
34
|
+
enqueue_method = :enqueue
|
35
|
+
if options[:at]
|
36
|
+
enqueue_method = :enqueue_at
|
37
|
+
args.unshift options[:at]
|
38
|
+
elsif options[:in]
|
39
|
+
enqueue_method = :enqueue_in
|
40
|
+
args.unshift options[:in]
|
41
|
+
end
|
42
|
+
ActionMailer::DeliveryJob.send enqueue_method, *args
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -11,6 +11,14 @@ module ActionMailer
|
|
11
11
|
#
|
12
12
|
mattr_accessor :preview_path, instance_writer: false
|
13
13
|
|
14
|
+
# Enable or disable mailer previews through app configuration:
|
15
|
+
#
|
16
|
+
# config.action_mailer.show_previews = true
|
17
|
+
#
|
18
|
+
# Defaults to true for development environment
|
19
|
+
#
|
20
|
+
mattr_accessor :show_previews, instance_writer: false
|
21
|
+
|
14
22
|
# :nodoc:
|
15
23
|
mattr_accessor :preview_interceptors, instance_writer: false
|
16
24
|
self.preview_interceptors = []
|
@@ -96,6 +104,10 @@ module ActionMailer
|
|
96
104
|
Base.preview_path
|
97
105
|
end
|
98
106
|
|
107
|
+
def show_previews #:nodoc:
|
108
|
+
Base.show_previews
|
109
|
+
end
|
110
|
+
|
99
111
|
def inform_preview_interceptors(message) #:nodoc:
|
100
112
|
Base.preview_interceptors.each do |interceptor|
|
101
113
|
interceptor.previewing_email(message)
|
@@ -18,8 +18,9 @@ module ActionMailer
|
|
18
18
|
options.assets_dir ||= paths["public"].first
|
19
19
|
options.javascripts_dir ||= paths["public/javascripts"].first
|
20
20
|
options.stylesheets_dir ||= paths["public/stylesheets"].first
|
21
|
+
options.show_previews = Rails.env.development? if options.show_previews.nil?
|
21
22
|
|
22
|
-
if
|
23
|
+
if options.show_previews
|
23
24
|
options.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil
|
24
25
|
end
|
25
26
|
|
@@ -29,7 +30,7 @@ module ActionMailer
|
|
29
30
|
|
30
31
|
ActiveSupport.on_load(:action_mailer) do
|
31
32
|
include AbstractController::UrlFor
|
32
|
-
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
|
33
|
+
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes, false)
|
33
34
|
include app.routes.mounted_helpers
|
34
35
|
|
35
36
|
register_interceptors(options.delete(:interceptors))
|
@@ -37,6 +38,13 @@ module ActionMailer
|
|
37
38
|
register_observers(options.delete(:observers))
|
38
39
|
|
39
40
|
options.each { |k,v| send("#{k}=", v) }
|
41
|
+
|
42
|
+
if options.show_previews
|
43
|
+
app.routes.append do
|
44
|
+
get '/rails/mailers' => "rails/mailers#index"
|
45
|
+
get '/rails/mailers/*path' => "rails/mailers#preview"
|
46
|
+
end
|
47
|
+
end
|
40
48
|
end
|
41
49
|
end
|
42
50
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support/test_case'
|
2
|
+
require 'rails-dom-testing'
|
2
3
|
|
3
4
|
module ActionMailer
|
4
5
|
class NonInferrableMailerError < ::StandardError
|
@@ -15,11 +16,13 @@ module ActionMailer
|
|
15
16
|
|
16
17
|
include ActiveSupport::Testing::ConstantLookup
|
17
18
|
include TestHelper
|
19
|
+
include Rails::Dom::Testing::Assertions::SelectorAssertions
|
18
20
|
|
19
21
|
included do
|
20
22
|
class_attribute :_mailer_class
|
21
23
|
setup :initialize_test_deliveries
|
22
24
|
setup :set_expected_mail
|
25
|
+
teardown :restore_test_deliveries
|
23
26
|
end
|
24
27
|
|
25
28
|
module ClassMethods
|
@@ -54,11 +57,26 @@ module ActionMailer
|
|
54
57
|
protected
|
55
58
|
|
56
59
|
def initialize_test_deliveries
|
57
|
-
|
60
|
+
set_delivery_method :test
|
61
|
+
@old_perform_deliveries = ActionMailer::Base.perform_deliveries
|
58
62
|
ActionMailer::Base.perform_deliveries = true
|
63
|
+
end
|
64
|
+
|
65
|
+
def restore_test_deliveries
|
66
|
+
restore_delivery_method
|
67
|
+
ActionMailer::Base.perform_deliveries = @old_perform_deliveries
|
59
68
|
ActionMailer::Base.deliveries.clear
|
60
69
|
end
|
61
70
|
|
71
|
+
def set_delivery_method(method)
|
72
|
+
@old_delivery_method = ActionMailer::Base.delivery_method
|
73
|
+
ActionMailer::Base.delivery_method = method
|
74
|
+
end
|
75
|
+
|
76
|
+
def restore_delivery_method
|
77
|
+
ActionMailer::Base.delivery_method = @old_delivery_method
|
78
|
+
end
|
79
|
+
|
62
80
|
def set_expected_mail
|
63
81
|
@expected = Mail.new
|
64
82
|
@expected.content_type ["text", "plain", { "charset" => charset }]
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require_relative 'gem_version'
|
2
2
|
|
3
3
|
module ActionMailer
|
4
|
-
# Returns the version of the currently loaded
|
4
|
+
# Returns the version of the currently loaded Action Mailer as a
|
5
|
+
# <tt>Gem::Version</tt>.
|
5
6
|
def self.version
|
6
7
|
gem_version
|
7
8
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0.beta1
|
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: 2014-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: 4.2.0.beta1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
26
|
+
version: 4.2.0.beta1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionview
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.
|
33
|
+
version: 4.2.0.beta1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.
|
40
|
+
version: 4.2.0.beta1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mail
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,6 +58,26 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 2.5.4
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rails-dom-testing
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.0'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.0.2
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.0'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.0.2
|
61
81
|
description: Email on Rails. Compose, deliver, receive, and test emails using the
|
62
82
|
familiar controller/view pattern. First-class support for multipart email and attachments.
|
63
83
|
email: david@loudthinking.com
|
@@ -71,11 +91,12 @@ files:
|
|
71
91
|
- lib/action_mailer.rb
|
72
92
|
- lib/action_mailer/base.rb
|
73
93
|
- lib/action_mailer/collector.rb
|
94
|
+
- lib/action_mailer/delivery_job.rb
|
74
95
|
- lib/action_mailer/delivery_methods.rb
|
75
96
|
- lib/action_mailer/gem_version.rb
|
76
|
-
- lib/action_mailer/inline_preview_interceptor.rb
|
77
97
|
- lib/action_mailer/log_subscriber.rb
|
78
98
|
- lib/action_mailer/mail_helper.rb
|
99
|
+
- lib/action_mailer/message_delivery.rb
|
79
100
|
- lib/action_mailer/preview.rb
|
80
101
|
- lib/action_mailer/railtie.rb
|
81
102
|
- lib/action_mailer/test_case.rb
|
@@ -99,13 +120,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
120
|
version: 1.9.3
|
100
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
122
|
requirements:
|
102
|
-
- - "
|
123
|
+
- - ">"
|
103
124
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
125
|
+
version: 1.3.1
|
105
126
|
requirements:
|
106
127
|
- none
|
107
128
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.2.2
|
109
130
|
signing_key:
|
110
131
|
specification_version: 4
|
111
132
|
summary: Email composition, delivery, and receiving framework (part of Rails).
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module ActionMailer
|
4
|
-
# Implements a mailer preview interceptor that converts image tag src attributes
|
5
|
-
# that use inline cid: style urls to data: style urls so that they are visible
|
6
|
-
# when previewing a HTML email in a web browser.
|
7
|
-
#
|
8
|
-
# This interceptor is not enabled by default, to use it just register it like any
|
9
|
-
# other mailer preview interceptor:
|
10
|
-
#
|
11
|
-
# ActionMailer::Base.register_preview_interceptor(ActionMailer::InlinePreviewInterceptor)
|
12
|
-
#
|
13
|
-
class InlinePreviewInterceptor
|
14
|
-
PATTERN = /src=(?:"cid:[^"]+"|'cid:[^']+')/i
|
15
|
-
|
16
|
-
include Base64
|
17
|
-
|
18
|
-
def self.previewing_email(message) #:nodoc:
|
19
|
-
new(message).transform!
|
20
|
-
end
|
21
|
-
|
22
|
-
def initialize(message) #:nodoc:
|
23
|
-
@message = message
|
24
|
-
end
|
25
|
-
|
26
|
-
def transform! #:nodoc:
|
27
|
-
return message if html_part.blank?
|
28
|
-
|
29
|
-
html_source.gsub!(PATTERN) do |match|
|
30
|
-
if part = find_part(match[9..-2])
|
31
|
-
%[src="#{data_url(part)}"]
|
32
|
-
else
|
33
|
-
match
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
message
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
def message
|
42
|
-
@message
|
43
|
-
end
|
44
|
-
|
45
|
-
def html_part
|
46
|
-
@html_part ||= message.html_part
|
47
|
-
end
|
48
|
-
|
49
|
-
def html_source
|
50
|
-
html_part.body.raw_source
|
51
|
-
end
|
52
|
-
|
53
|
-
def data_url(part)
|
54
|
-
"data:#{part.mime_type};base64,#{strict_encode64(part.body.raw_source)}"
|
55
|
-
end
|
56
|
-
|
57
|
-
def find_part(cid)
|
58
|
-
message.all_parts.find{ |p| p.attachment? && p.cid == cid }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|