sendgrid-actionmailer 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e7c4317fb02b1c622b8142161339d320a1a0b49e10e2f1c8cf98c9c649e432f
4
- data.tar.gz: 33772e1a2200cd9bdd239792b1e4c3339d13e662944afb3782399eeeaad7ac5e
3
+ metadata.gz: a88b2d06241fbea431221f6f1ad9fcde082aefb5467a0f4b3f48aace1f544014
4
+ data.tar.gz: 5dc1e5a5ca5bd0f8e5bf70f10cc3098962998f82c649a8d9ef19c529d8992038
5
5
  SHA512:
6
- metadata.gz: df22bdee0b6fbd56a2827d56b4115ec1cc62454e0ca8dc8b32bdd165699df16895a328c1b679868eee145424535b8b0f2ed0447e8e6f70e4154b6c962ed643c9
7
- data.tar.gz: 5ceb138422116c59a4dd3d76a0197a1fe4f80dbbcdaadedf5969e328bda9a4091a5bf15f268c715d0f928ff7e8b912c5ace8556b41cbefb408124a740ce48e45
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
- case mail.mime_type
151
- when 'text/plain'
152
- sendgrid_mail.add_content(to_content(:plain, mail.body.decoded))
153
- when 'text/html'
154
- sendgrid_mail.add_content(to_content(:html, mail.body.decoded))
155
- when 'multipart/alternative', 'multipart/mixed', 'multipart/related'
156
- sendgrid_mail.add_content(to_content(:plain, mail.text_part.decoded)) if mail.text_part
157
- sendgrid_mail.add_content(to_content(:html, mail.html_part.decoded)) if mail.html_part
158
-
159
- mail.attachments.each do |part|
160
- sendgrid_mail.add_attachment(to_attachment(part))
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
@@ -1,3 +1,3 @@
1
1
  module SendGridActionMailer
2
- VERSION = '2.5.0'.freeze
2
+ VERSION = '2.6.0'.freeze
3
3
  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.5.0
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-21 00:00:00.000000000 Z
13
+ date: 2020-01-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mail