sendgrid-actionmailer 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sendgrid_actionmailer.rb +21 -11
- data/lib/sendgrid_actionmailer/version.rb +1 -1
- data/spec/lib/sendgrid_actionmailer_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a88b2d06241fbea431221f6f1ad9fcde082aefb5467a0f4b3f48aace1f544014
|
4
|
+
data.tar.gz: 5dc1e5a5ca5bd0f8e5bf70f10cc3098962998f82c649a8d9ef19c529d8992038
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c84a47a7a8f1dfe6a795688ad8c351736b5ebd86adaf1358100b6a8ffc3bad0ad0bfdfaf014ba6a9aaa9d13dc35c0491d0415ef1c54df7b405dfd11485bb54fb
|
7
|
+
data.tar.gz: 8a604292f2bb61541fbe7476e5599d392118b0797edbe35751112b181347aab07fef6d28d849977ff76dd022eab9cdef0dea9d7a0aadd82fd7af6f0dd6c09704
|
@@ -146,18 +146,28 @@ module SendGridActionMailer
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
+
def add_attachments(sendgrid_mail, mail)
|
150
|
+
mail.attachments.each do |part|
|
151
|
+
sendgrid_mail.add_attachment(to_attachment(part))
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
149
155
|
def add_content(sendgrid_mail, mail)
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
156
|
+
if mail['template_id']
|
157
|
+
# We are sending a template, so we don't need to add any content outside
|
158
|
+
# of attachments
|
159
|
+
add_attachments(sendgrid_mail, mail)
|
160
|
+
else
|
161
|
+
case mail.mime_type
|
162
|
+
when 'text/plain'
|
163
|
+
sendgrid_mail.add_content(to_content(:plain, mail.body.decoded))
|
164
|
+
when 'text/html'
|
165
|
+
sendgrid_mail.add_content(to_content(:html, mail.body.decoded))
|
166
|
+
when 'multipart/alternative', 'multipart/mixed', 'multipart/related'
|
167
|
+
sendgrid_mail.add_content(to_content(:plain, mail.text_part.decoded)) if mail.text_part
|
168
|
+
sendgrid_mail.add_content(to_content(:html, mail.html_part.decoded)) if mail.html_part
|
169
|
+
|
170
|
+
add_attachments(sendgrid_mail, mail)
|
161
171
|
end
|
162
172
|
end
|
163
173
|
end
|
@@ -264,6 +264,20 @@ module SendGridActionMailer
|
|
264
264
|
mailer.deliver!(mail)
|
265
265
|
expect(client.sent_mail['personalizations'].first).to_not have_key('substitutions')
|
266
266
|
end
|
267
|
+
|
268
|
+
it 'does not set send a content type' do
|
269
|
+
mailer.deliver!(mail)
|
270
|
+
expect(client.sent_mail['content']).to eq(nil)
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'does not set send a content type even if body is given' do
|
274
|
+
# This matches the default behavior of ActionMail. body must be
|
275
|
+
# specified and content_type defaults to text/plain.
|
276
|
+
mail.body = 'I heard you like pineapple.'
|
277
|
+
mail.content_type = 'text/plain'
|
278
|
+
mailer.deliver!(mail)
|
279
|
+
expect(client.sent_mail['content']).to eq(nil)
|
280
|
+
end
|
267
281
|
end
|
268
282
|
|
269
283
|
context 'without dynamic template data or a template id' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendgrid-actionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eddie Zaneski
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-01-
|
13
|
+
date: 2020-01-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mail
|