sendgrid-actionmailer 2.6.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a88b2d06241fbea431221f6f1ad9fcde082aefb5467a0f4b3f48aace1f544014
4
- data.tar.gz: 5dc1e5a5ca5bd0f8e5bf70f10cc3098962998f82c649a8d9ef19c529d8992038
3
+ metadata.gz: 8d75cda77ec587c85751c71dd79de21562a35e38562ae691dbd164ec86eae8bf
4
+ data.tar.gz: 8ba014c01b1e37162bb96a7c6b2c00a59c8a6ad9ad7eef126cacd1046dd03d60
5
5
  SHA512:
6
- metadata.gz: c84a47a7a8f1dfe6a795688ad8c351736b5ebd86adaf1358100b6a8ffc3bad0ad0bfdfaf014ba6a9aaa9d13dc35c0491d0415ef1c54df7b405dfd11485bb54fb
7
- data.tar.gz: 8a604292f2bb61541fbe7476e5599d392118b0797edbe35751112b181347aab07fef6d28d849977ff76dd022eab9cdef0dea9d7a0aadd82fd7af6f0dd6c09704
6
+ metadata.gz: 5c425f306373fd3a70490aacf0e55e312827bdf94b24f33d602bd3dd0335c66682f0352ed9ffe964e50c6dd4a6a99a4ec8cbcca24f1b2e7dfa6e195e63fd00be
7
+ data.tar.gz: 91bf36ef8d4e4a1fd8de5e019f94f9486ae3ea106240256c7c8a08a84c3ebceceab49c348b26936ddc6162e32eb82739646a80b8df6df393855071acb353488e
@@ -9,6 +9,4 @@ before_install:
9
9
  - gem update --system
10
10
  - gem install bundler
11
11
  gemfile:
12
- - gemfiles/mail_2.5.gemfile
13
- - gemfiles/mail_2.6.gemfile
14
12
  - gemfiles/mail_2.7.gemfile
data/Appraisals CHANGED
@@ -1,11 +1,3 @@
1
- appraise "mail-2.5" do
2
- gem "mail", "2.5.4"
3
- end
4
-
5
- appraise "mail-2.6" do
6
- gem "mail", "2.6.4"
7
- end
8
-
9
1
  appraise "mail-2.7" do
10
2
  gem "mail", "2.7.0"
11
3
  end
@@ -1,5 +1,42 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.0.0 - 2020-3-2
4
+
5
+ ### Removed
6
+
7
+ - Compatibility with mail gems before version 2.7
8
+
9
+ ## 2.6.0 - 2020-1-23
10
+
11
+ ### Chages
12
+
13
+ - Dont send content types with dynamic templates (#69)
14
+
15
+ ## 2.5.0 - 2020-1-21
16
+
17
+ ### Chages
18
+
19
+ - Add personalizations field (#60)
20
+
21
+ ### Fixes
22
+
23
+ - Revert "Lazy load ActionMailer::Base" (#64)
24
+ - Yank 2.4.1
25
+
26
+ ## 2.4.2 - 2020-1-21
27
+
28
+ ### Fixes
29
+
30
+ - Revert "Lazy load ActionMailer::Base" (#64)
31
+ - Yank 2.4.1
32
+
33
+ ## 2.4.1 - 2020-1-20
34
+
35
+ ### Changed
36
+
37
+ - Update Travis CI settings to test on latest Ruby and mail gem version (#55)
38
+ - Lazy load ActionMailer::Base (#57)
39
+
3
40
  ## 2.4.0 - 2019-07-9
4
41
 
5
42
  ### Changed
@@ -4,6 +4,7 @@ require 'sendgrid-ruby'
4
4
 
5
5
  module SendGridActionMailer
6
6
  class DeliveryMethod
7
+
7
8
  # TODO: use custom class to customer excpetion payload
8
9
  SendgridDeliveryError = Class.new(StandardError)
9
10
 
@@ -74,48 +75,50 @@ module SendGridActionMailer
74
75
  end
75
76
 
76
77
  def setup_personalization(mail, personalization_hash)
77
- p = Personalization.new
78
+ personalization = Personalization.new
79
+
80
+ personalization_hash = self.class.transform_keys(personalization_hash, &:to_s)
78
81
 
79
82
  (personalization_hash['to'] || []).each do |to|
80
- p.add_to Email.new(email: to['email'], name: to['name'])
83
+ personalization.add_to Email.new(email: to['email'], name: to['name'])
81
84
  end
82
85
  (personalization_hash['cc'] || []).each do |cc|
83
- p.add_cc Email.new(email: cc['email'], name: cc['name'])
86
+ personalization.add_cc Email.new(email: cc['email'], name: cc['name'])
84
87
  end
85
88
  (personalization_hash['bcc'] || []).each do |bcc|
86
- p.add_bcc Email.new(email: bcc['email'], name: bcc['name'])
89
+ personalization.add_bcc Email.new(email: bcc['email'], name: bcc['name'])
87
90
  end
88
91
  (personalization_hash['headers'] || []).each do |header_key, header_value|
89
- p.add_header Header.new(key: header_key, value: header_value)
92
+ personalization.add_header Header.new(key: header_key, value: header_value)
90
93
  end
91
94
  (personalization_hash['substitutions'] || {}).each do |sub_key, sub_value|
92
- p.add_substitution(Substitution.new(key: sub_key, value: sub_value))
95
+ personalization.add_substitution(Substitution.new(key: sub_key, value: sub_value))
93
96
  end
94
97
  (personalization_hash['custom_args'] || {}).each do |arg_key, arg_value|
95
- p.add_custom_arg(CustomArg.new(key: arg_key, value: arg_value))
98
+ personalization.add_custom_arg(CustomArg.new(key: arg_key, value: arg_value))
96
99
  end
97
100
  if personalization_hash['send_at']
98
- p.send_at = personalization_hash['send_at']
101
+ personalization.send_at = personalization_hash['send_at']
99
102
  end
100
103
  if personalization_hash['subject']
101
- p.subject = personalization_hash['subject']
104
+ personalization.subject = personalization_hash['subject']
102
105
  end
103
106
 
104
107
  if mail['dynamic_template_data'] || personalization_hash['dynamic_template_data']
105
108
  if mail['dynamic_template_data']
106
- data = json_parse(mail['dynamic_template_data'].value, false)
109
+ data = mail['dynamic_template_data'].unparsed_value
107
110
  data.merge!(personalization_hash['dynamic_template_data'] || {})
108
111
  else
109
112
  data = personalization_hash['dynamic_template_data']
110
113
  end
111
- p.add_dynamic_template_data(data)
114
+ personalization.add_dynamic_template_data(data)
112
115
  elsif mail['template_id'].nil?
113
- p.add_substitution(Substitution.new(key: "%asm_group_unsubscribe_raw_url%", value: "<%asm_group_unsubscribe_raw_url%>"))
114
- p.add_substitution(Substitution.new(key: "%asm_global_unsubscribe_raw_url%", value: "<%asm_global_unsubscribe_raw_url%>"))
115
- p.add_substitution(Substitution.new(key: "%asm_preferences_raw_url%", value: "<%asm_preferences_raw_url%>"))
116
+ personalization.add_substitution(Substitution.new(key: "%asm_group_unsubscribe_raw_url%", value: "<%asm_group_unsubscribe_raw_url%>"))
117
+ personalization.add_substitution(Substitution.new(key: "%asm_global_unsubscribe_raw_url%", value: "<%asm_global_unsubscribe_raw_url%>"))
118
+ personalization.add_substitution(Substitution.new(key: "%asm_preferences_raw_url%", value: "<%asm_preferences_raw_url%>"))
116
119
  end
117
120
 
118
- p
121
+ return personalization
119
122
  end
120
123
 
121
124
  def to_attachment(part)
@@ -142,7 +145,7 @@ module SendGridActionMailer
142
145
  def add_api_key(sendgrid_mail, mail)
143
146
  self.api_key = settings.fetch(:api_key)
144
147
  if mail['delivery-method-options'] && mail['delivery-method-options'].value.include?('api_key')
145
- self.api_key = JSON.parse(mail['delivery-method-options'].value.gsub('=>', ':'))['api_key']
148
+ self.api_key = mail['delivery-method-options'].unparsed_value['api_key']
146
149
  end
147
150
  end
148
151
 
@@ -172,11 +175,12 @@ module SendGridActionMailer
172
175
  end
173
176
  end
174
177
 
175
- def json_parse(text, symbolize=true)
176
- JSON.parse(text.empty? ? '{}' : text.gsub(/:*\"*([\%a-zA-Z0-9_-]*)\"*(( *)=>\ *)/) { "\"#{$1}\":" }, symbolize_names: symbolize)
177
- end
178
-
179
178
  def add_personalizations(sendgrid_mail, mail)
179
+ if mail['personalizations']
180
+ mail['personalizations'].unparsed_value.each do |p|
181
+ sendgrid_mail.add_personalization(setup_personalization(mail, p))
182
+ end
183
+ end
180
184
  if (mail.to && mail.to.any?) || (mail.cc && mail.cc.any?) || (mail.bcc && mail.bcc.any?)
181
185
  personalization = setup_personalization(mail, {})
182
186
  to_emails(mail.to).each { |to| personalization.add_to(to) }
@@ -184,13 +188,6 @@ module SendGridActionMailer
184
188
  to_emails(mail.bcc).each { |bcc| personalization.add_bcc(bcc) }
185
189
  sendgrid_mail.add_personalization(personalization)
186
190
  end
187
-
188
- if mail['personalizations']
189
- personalizations = json_parse('[' + mail['personalizations'].value + ']', false)
190
- personalizations.each do |p|
191
- sendgrid_mail.add_personalization(setup_personalization(mail, p))
192
- end
193
- end
194
191
  end
195
192
 
196
193
  def add_send_options(sendgrid_mail, mail)
@@ -198,12 +195,12 @@ module SendGridActionMailer
198
195
  sendgrid_mail.template_id = mail['template_id'].to_s
199
196
  end
200
197
  if mail['sections']
201
- json_parse(mail['sections'].value, false).each do |key, value|
198
+ mail['sections'].unparsed_value.each do |key, value|
202
199
  sendgrid_mail.add_section(Section.new(key: key, value: value))
203
200
  end
204
201
  end
205
202
  if mail['headers']
206
- json_parse(mail['headers'].value, false).each do |key, value|
203
+ mail['headers'].unparsed_value.each do |key, value|
207
204
  sendgrid_mail.add_header(Header.new(key: key, value: value))
208
205
  end
209
206
  end
@@ -213,7 +210,7 @@ module SendGridActionMailer
213
210
  end
214
211
  end
215
212
  if mail['custom_args']
216
- json_parse(mail['custom_args'].value, false).each do |key, value|
213
+ mail['custom_args'].unparsed_value.each do |key, value|
217
214
  sendgrid_mail.add_custom_arg(CustomArg.new(key: key, value: value))
218
215
  end
219
216
  end
@@ -224,9 +221,10 @@ module SendGridActionMailer
224
221
  sendgrid_mail.batch_id = mail['batch_id'].to_s
225
222
  end
226
223
  if mail['asm']
227
- asm = json_parse(mail['asm'].value)
228
- asm = asm.delete_if { |key, value| !key.to_s.match(/(group_id)|(groups_to_display)/) }
229
- if asm[:group_id]
224
+ asm = mail['asm'].unparsed_value
225
+ asm = asm.delete_if { |key, value|
226
+ !key.to_s.match(/(group_id)|(groups_to_display)/) }
227
+ if asm.keys.map(&:to_s).include?('group_id')
230
228
  sendgrid_mail.asm = ASM.new(asm)
231
229
  end
232
230
  end
@@ -237,7 +235,7 @@ module SendGridActionMailer
237
235
 
238
236
  def add_mail_settings(sendgrid_mail, mail)
239
237
  if mail['mail_settings']
240
- settings = json_parse(mail['mail_settings'].value)
238
+ settings = mail['mail_settings'].unparsed_value || {}
241
239
  sendgrid_mail.mail_settings = MailSettings.new.tap do |m|
242
240
  if settings[:bcc]
243
241
  m.bcc = BccSettings.new(settings[:bcc])
@@ -260,7 +258,7 @@ module SendGridActionMailer
260
258
 
261
259
  def add_tracking_settings(sendgrid_mail, mail)
262
260
  if mail['tracking_settings']
263
- settings = json_parse(mail['tracking_settings'].value)
261
+ settings = mail['tracking_settings'].unparsed_value
264
262
  sendgrid_mail.tracking_settings = TrackingSettings.new.tap do |t|
265
263
  if settings[:click_tracking]
266
264
  t.click_tracking = ClickTracking.new(settings[:click_tracking])
@@ -290,5 +288,17 @@ module SendGridActionMailer
290
288
 
291
289
  result
292
290
  end
291
+
292
+ # Recursive key transformation based on Rails deep_transform_values
293
+ def self.transform_keys(object, &block)
294
+ case object
295
+ when Hash
296
+ object.map { |key, value| [yield(key), transform_keys(value, &block)] }.to_h
297
+ when Array
298
+ object.map { |e| transform_keys(e, &block) }
299
+ else
300
+ object
301
+ end
302
+ end
293
303
  end
294
304
  end
@@ -1,3 +1,3 @@
1
1
  module SendGridActionMailer
2
- VERSION = '2.6.0'.freeze
2
+ VERSION = '3.0.0'.freeze
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency 'mail', '~> 2.5'
22
+ spec.add_dependency 'mail', '~> 2.7'
23
23
  spec.add_dependency 'sendgrid-ruby', '~> 6.0'
24
24
 
25
25
  spec.add_development_dependency 'appraisal', '~> 2.1.0'
@@ -3,12 +3,8 @@ require 'webmock/rspec'
3
3
 
4
4
  module SendGridActionMailer
5
5
  describe DeliveryMethod do
6
- def stringify_keys(hash)
7
- result = {}
8
- hash.each_key do |key|
9
- result[key.to_s] = hash[key]
10
- end
11
- result
6
+ def transform_keys(object, &block)
7
+ SendGridActionMailer::DeliveryMethod.transform_keys(object, &block)
12
8
  end
13
9
 
14
10
  subject(:mailer) do
@@ -329,10 +325,10 @@ module SendGridActionMailer
329
325
  end
330
326
 
331
327
  it 'sets asm' do
332
- asm = {'group_id' => 99, 'groups_to_display' => [4,5,6,7,8]}
328
+ asm = {group_id: 99, groups_to_display: [4,5,6,7,8]}
333
329
  mail['asm'] = asm
334
330
  mailer.deliver!(mail)
335
- expect(client.sent_mail['asm']).to eq(asm)
331
+ expect(client.sent_mail['asm']).to eq(transform_keys(asm, &:to_s))
336
332
  end
337
333
 
338
334
  it 'sets ip_pool_name' do
@@ -341,93 +337,77 @@ module SendGridActionMailer
341
337
  expect(client.sent_mail['ip_pool_name']).to eq('marketing')
342
338
  end
343
339
 
344
- context 'parse object' do
345
- it "should parse 1.8 hash" do
346
- asm = {'group_id' => 99, 'groups_to_display' => [4,5,6,7,8]}
347
- mail['asm'] = asm
348
- mailer.deliver!(mail)
349
- expect(client.sent_mail['asm']).to eq({"group_id" => 99, "groups_to_display" => [4,5,6,7,8]})
350
- end
351
-
352
- it "should parse 1.9 hash" do
353
- asm = { group_id: 99, groups_to_display: [4,5,6,7,8]}
354
- mail['asm'] = asm
355
- mailer.deliver!(mail)
356
- expect(client.sent_mail['asm']).to eq({"group_id" => 99, "groups_to_display" => [4,5,6,7,8]})
357
- end
358
-
359
- it "should parse json" do
360
- asm = {'group_id' => 99, 'groups_to_display' => [4,5,6,7,8]}
361
- mail['asm'] = asm.to_json
362
- mailer.deliver!(mail)
363
- expect(client.sent_mail['asm']).to eq({"group_id" => 99, "groups_to_display" => [4,5,6,7,8]})
364
- end
340
+ it 'should not change values inside custom args' do
341
+ custom_args = { 'text' => 'line with a => in it' }
342
+ mail['custom_args'] = custom_args
343
+ mailer.deliver!(mail)
344
+ expect(client.sent_mail['custom_args']).to eq('text' => 'line with a => in it')
365
345
  end
366
346
 
367
347
  context 'mail_settings' do
368
348
  it 'sets bcc' do
369
- bcc = { 'bcc' => { 'enable' => true, 'email' => 'test@example.com' }}
349
+ bcc = { bcc: { enable: true, email: 'test@example.com' }}
370
350
  mail['mail_settings'] = bcc
371
351
  mailer.deliver!(mail)
372
- expect(client.sent_mail['mail_settings']).to eq(bcc)
352
+ expect(client.sent_mail['mail_settings']).to eq(transform_keys(bcc, &:to_s))
373
353
  end
374
354
 
375
355
  it 'sets bypass_list_management' do
376
- bypass = { 'bypass_list_management' => { 'enable' => true }}
356
+ bypass = { bypass_list_management: { enable: true }}
377
357
  mail['mail_settings'] = bypass
378
358
  mailer.deliver!(mail)
379
- expect(client.sent_mail['mail_settings']).to eq(bypass)
359
+ expect(client.sent_mail['mail_settings']).to eq(transform_keys(bypass, &:to_s))
380
360
  end
381
361
 
382
362
  it 'sets footer' do
383
- footer = {'footer' => { 'enable' => true, 'text' => 'Footer Text', 'html' => '<html><body>Footer Text</body></html>'}}
363
+ footer = {footer: { enable: true, text: 'Footer Text', html: '<html><body>Footer Text</body></html>'}}
384
364
  mail['mail_settings'] = footer
385
365
  mailer.deliver!(mail)
386
- expect(client.sent_mail['mail_settings']).to eq(footer)
366
+ expect(client.sent_mail['mail_settings']).to eq(transform_keys(footer, &:to_s))
387
367
  end
388
368
 
389
369
  it 'sets sandbox_mode' do
390
- sandbox = {'sandbox_mode' => { 'enable' => true }}
370
+ sandbox = {sandbox_mode: { enable: true }}
391
371
  mail['mail_settings'] = sandbox
392
372
  mailer.deliver!(mail)
393
- expect(client.sent_mail['mail_settings']).to eq(sandbox)
373
+ expect(client.sent_mail['mail_settings']).to eq(transform_keys(sandbox, &:to_s))
394
374
  end
395
375
 
396
376
  it 'sets spam_check' do
397
- spam_check = {'spam_check' => { 'enable' => true, 'threshold' => 1, 'post_to_url' => 'https://spamcatcher.sendgrid.com'}}
377
+ spam_check = {spam_check: { enable: true, threshold: 1, post_to_url: 'https://spamcatcher.sendgrid.com'}}
398
378
  mail['mail_settings'] = spam_check
399
379
  mailer.deliver!(mail)
400
- expect(client.sent_mail['mail_settings']).to eq(spam_check)
380
+ expect(client.sent_mail['mail_settings']).to eq(transform_keys(spam_check, &:to_s))
401
381
  end
402
382
  end
403
383
 
404
384
  context 'tracking_settings' do
405
385
  it 'sets click_tracking' do
406
- tracking = { 'click_tracking' => { 'enable' => false, 'enable_text' => false }}
407
- mail['tracking_settings'] = tracking
386
+ tracking = { click_tracking: { enable: false, enable_text: false }}
387
+ mail['tracking_settings'] = tracking.dup
408
388
  mailer.deliver!(mail)
409
- expect(client.sent_mail['tracking_settings']).to eq(tracking)
389
+ expect(client.sent_mail['tracking_settings']).to eq(transform_keys(tracking, &:to_s))
410
390
  end
411
391
 
412
392
  it 'sets open_tracking' do
413
- tracking = { 'open_tracking' => { 'enable' => true, 'substitution_tag' => 'Optional tag to replace with the open image in the body of the message' }}
393
+ tracking = { open_tracking: { enable: true, substitution_tag: 'Optional tag to replace with the open image in the body of the message' }}
414
394
  mail['tracking_settings'] = tracking
415
395
  mailer.deliver!(mail)
416
- expect(client.sent_mail['tracking_settings']).to eq(tracking)
396
+ expect(client.sent_mail['tracking_settings']).to eq(transform_keys(tracking, &:to_s))
417
397
  end
418
398
 
419
399
  it 'sets subscription_tracking' do
420
- tracking = { 'subscription_tracking' => { 'enable' => true, 'text' => 'text to insert into the text/plain portion of the message', 'html' => 'html to insert into the text/html portion of the message', 'substitution_tag' => 'Optional tag to replace with the open image in the body of the def message' }}
400
+ tracking = { subscription_tracking: { enable: true, text: 'text to insert into the text/plain portion of the message', html: 'html to insert into the text/html portion of the message', substitution_tag: 'Optional tag to replace with the open image in the body of the def message' }}
421
401
  mail['tracking_settings'] = tracking
422
402
  mailer.deliver!(mail)
423
- expect(client.sent_mail['tracking_settings']).to eq(tracking)
403
+ expect(client.sent_mail['tracking_settings']).to eq(transform_keys(tracking, &:to_s))
424
404
  end
425
405
 
426
406
  it 'sets ganalytics' do
427
- tracking = { 'ganalytics' => {'enable' => true, 'utm_source' => 'some source', 'utm_medium' => 'some medium', 'utm_term' => 'some term', 'utm_content' => 'some content', 'utm_campaign' => 'some campaign' }}
407
+ tracking = { ganalytics: { enable: true, utm_source: 'some source', utm_medium: 'some medium', utm_term: 'some term', utm_content: 'some content', utm_campaign: 'some campaign' }}
428
408
  mail['tracking_settings'] = tracking
429
409
  mailer.deliver!(mail)
430
- expect(client.sent_mail['tracking_settings']).to eq(tracking)
410
+ expect(client.sent_mail['tracking_settings']).to eq(transform_keys(tracking, &:to_s))
431
411
  end
432
412
  end
433
413
 
@@ -440,19 +420,26 @@ module SendGridActionMailer
440
420
 
441
421
  it 'sets dynamic_template_data' do
442
422
  mailer.deliver!(mail)
443
- expect(client.sent_mail['personalizations'].first['dynamic_template_data']).to eq({'variable_1' => '1', 'variable_2' => '2'})
423
+ expect(client.sent_mail['personalizations'].first['dynamic_template_data']).to eq(template_data)
444
424
  end
445
425
 
446
426
  it 'does not set unsubscribe substitutions' do
447
427
  mailer.deliver!(mail)
448
428
  expect(client.sent_mail['personalizations'].first).to_not have_key('substitutions')
449
429
  end
450
- end
451
430
 
452
- it 'sets dynamic template data and sandbox_mode' do
453
- mail['mail_settings'] = '{}'
454
- mailer.deliver!(mail)
455
- expect(client.sent_mail['mail_settings']).to eq(nil)
431
+ context 'containing what looks like hash syntax' do
432
+ let(:template_data) do
433
+ { hint: 'Just use => instead of :' }
434
+ end
435
+
436
+ it 'does not change values inside dynamic template data' do
437
+ mailer.deliver!(mail)
438
+ expect(
439
+ client.sent_mail['personalizations'].first['dynamic_template_data']
440
+ ).to eq(template_data)
441
+ end
442
+ end
456
443
  end
457
444
 
458
445
  it 'sets dynamic template data and sandbox_mode' do
@@ -670,20 +657,21 @@ module SendGridActionMailer
670
657
  end
671
658
 
672
659
  context 'with symbols used as keys' do
673
- let(:personalizations) do
674
- [
675
- {
676
- to: [
677
- { email: 'john1@example.com', name: 'John 1'}
678
- ]
679
- }
680
- ]
660
+ let(:personalizations) do
661
+ [
662
+ {
663
+ to: [
664
+ {email: 'sally1@example.com', name: 'Sally 1'},
665
+ {email: 'sally2@example.com', name: 'Sally 2'},
666
+ ]
667
+ }
668
+ ]
681
669
  end
682
670
 
683
671
  it 'still works' do
684
672
  mailer.deliver!(mail)
685
673
  expect(client.sent_mail['personalizations'].length).to eq(1)
686
- expected_to = personalizations[0][:to].map { |t| stringify_keys(t) }
674
+ expected_to = personalizations[0][:to].map { |t| transform_keys(t, &:to_s) }
687
675
  expect(client.sent_mail['personalizations'][0]['to']).to eq(expected_to)
688
676
  end
689
677
  end
@@ -717,7 +705,7 @@ module SendGridActionMailer
717
705
  { 'variable_3' => '1', 'variable_4' => '2' }
718
706
  end
719
707
 
720
- before { mail['dynamic_template_data'] = mail_template_data }
708
+ before { mail['dynamic_template_data'] = mail_template_data.dup }
721
709
 
722
710
  it 'sets dynamic_template_data where not also provided as a personalization' do
723
711
  mailer.deliver!(mail)
@@ -739,9 +727,9 @@ module SendGridActionMailer
739
727
  it 'adds that to address as a separate personalization' do
740
728
  mailer.deliver!(mail)
741
729
  expect(client.sent_mail['personalizations'].length).to eq(3)
742
- expect(client.sent_mail['personalizations'][0]['to']).to eq([{"email"=>"test@sendgrid.com"}])
743
- expect(client.sent_mail['personalizations'][1]['to']).to eq(personalizations[0]['to'])
744
- expect(client.sent_mail['personalizations'][2]['to']).to eq(personalizations[1]['to'])
730
+ expect(client.sent_mail['personalizations'][0]['to']).to eq(personalizations[0]['to'])
731
+ expect(client.sent_mail['personalizations'][1]['to']).to eq(personalizations[1]['to'])
732
+ expect(client.sent_mail['personalizations'][2]['to']).to eq([{"email"=>"test@sendgrid.com"}])
745
733
  end
746
734
  end
747
735
 
@@ -751,9 +739,9 @@ module SendGridActionMailer
751
739
  it 'adds that cc address as a separate personalization' do
752
740
  mailer.deliver!(mail)
753
741
  expect(client.sent_mail['personalizations'].length).to eq(3)
754
- expect(client.sent_mail['personalizations'][0]['cc']).to eq([{"email"=>"test@sendgrid.com"}])
755
- expect(client.sent_mail['personalizations'][1]['cc']).to eq(personalizations[0]['cc'])
756
- expect(client.sent_mail['personalizations'][2]['cc']).to eq(personalizations[1]['cc'])
742
+ expect(client.sent_mail['personalizations'][0]['cc']).to eq(personalizations[0]['cc'])
743
+ expect(client.sent_mail['personalizations'][1]['cc']).to eq(personalizations[1]['cc'])
744
+ expect(client.sent_mail['personalizations'][2]['cc']).to eq([{"email"=>"test@sendgrid.com"}])
757
745
  end
758
746
  end
759
747
 
@@ -763,9 +751,9 @@ module SendGridActionMailer
763
751
  it 'adds that bcc address as a separate personalization' do
764
752
  mailer.deliver!(mail)
765
753
  expect(client.sent_mail['personalizations'].length).to eq(3)
766
- expect(client.sent_mail['personalizations'][0]['bcc']).to eq([{"email"=>"test@sendgrid.com"}])
767
- expect(client.sent_mail['personalizations'][1]['bcc']).to eq(personalizations[0]['bcc'])
768
- expect(client.sent_mail['personalizations'][2]['bcc']).to eq(personalizations[1]['bcc'])
754
+ expect(client.sent_mail['personalizations'][0]['bcc']).to eq(personalizations[0]['bcc'])
755
+ expect(client.sent_mail['personalizations'][1]['bcc']).to eq(personalizations[1]['bcc'])
756
+ expect(client.sent_mail['personalizations'][2]['bcc']).to eq([{"email"=>"test@sendgrid.com"}])
769
757
  end
770
758
  end
771
759
  end
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.6.0
4
+ version: 3.0.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-23 00:00:00.000000000 Z
13
+ date: 2020-03-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mail
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '2.5'
21
+ version: '2.7'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '2.5'
28
+ version: '2.7'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: sendgrid-ruby
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -128,8 +128,6 @@ files:
128
128
  - LICENSE.txt
129
129
  - README.md
130
130
  - Rakefile
131
- - gemfiles/mail_2.5.gemfile
132
- - gemfiles/mail_2.6.gemfile
133
131
  - gemfiles/mail_2.7.gemfile
134
132
  - lib/sendgrid-actionmailer.rb
135
133
  - lib/sendgrid_actionmailer.rb
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "mail", "2.5.5"
6
-
7
- gemspec :path => "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "mail", "2.6.6"
6
-
7
- gemspec :path => "../"