sendgrid-actionmailer 3.1.0 → 3.1.1

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: 65e252ac43443369106264d0b1b33c111184aede536c0b753798e91cd7c55e22
4
- data.tar.gz: df787ee4c8c4c40b3a8ceeffb89fae8c162360a84960cb094e04dff096990250
3
+ metadata.gz: 68926bb0db0f0f622282b8429b3df0f86911ca0d72c0146bcaf181966130e290
4
+ data.tar.gz: '048ca01e72420c6f88be723ada69126d31c831f300b0aa539f8f7d236e3c500f'
5
5
  SHA512:
6
- metadata.gz: 74792717f19a0ca85d4c450faf2936e318d0d1885ec922a9522b43ac1a1911aa791f5790d6331a56a0c43d7ec190fc1fdfbfdc0033fc52494755c5ea560b0257
7
- data.tar.gz: 45f55ecee835b2f49cff9fc16fc8845dd499ef9195f7e39737da6e83abb61d537b19293172758a7f682b3f4ba9388639d4052da11aff75841a581d52aec9e9b0
6
+ metadata.gz: 5999a6b88c2eb27869872a42c0f7300198cb9870f20087a9c38c68909b0bdcd6a960d0adc2eb01dfa39c530ff6eabee727e0ad9762b19294d57be8fd26e598f0
7
+ data.tar.gz: a26c201d0a9466684796371b82d2cb3d2aaad48efd1fc6a5c1ffd22b410bcdb71203379c498c8ae504653d0a2692206003ac3176ecfd32025e555fb38ebc0d2e
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.1.1 - 2020-11-06
4
+ - #92 globally configured mail_settings
5
+ - #95 add_mail_settings - support global settings
6
+
3
7
  ## 3.1.0 - 2020-8-03
4
8
 
5
9
  ### Changes
data/README.md CHANGED
@@ -24,6 +24,18 @@ Normal ActionMailer usage will now transparently be sent using SendGrid's Web AP
24
24
 
25
25
  ```mail(to: 'example@email.com', subject: 'email subject', body: 'email body')```
26
26
 
27
+ ### Mail Settings
28
+
29
+ Mail settings, such as sandbox_mode, may be applied globally through the sendgrid_actionmailer_settings configuration.
30
+
31
+ ```ruby
32
+ config.action_mailer.delivery_method = :sendgrid_actionmailer
33
+ config.action_mailer.sendgrid_actionmailer_settings = {
34
+ api_key: ENV['SENDGRID_API_KEY'],
35
+ mail_settings: { sandbox_mode: { enable: true }}
36
+ }
37
+ ```
38
+
27
39
  ### Dynamic API Key
28
40
 
29
41
  If you need to send mail for a number of Sendgrid accounts, you can set the API key for these as follows:
@@ -238,8 +238,10 @@ module SendGridActionMailer
238
238
  end
239
239
 
240
240
  def add_mail_settings(sendgrid_mail, mail)
241
- if mail['mail_settings']
242
- settings = mail['mail_settings'].unparsed_value || {}
241
+ local_settings = mail['mail_settings'] && mail['mail_settings'].unparsed_value || {}
242
+ global_settings = self.settings[:mail_settings] || {}
243
+ settings = global_settings.merge(local_settings)
244
+ unless settings.empty?
243
245
  sendgrid_mail.mail_settings = MailSettings.new.tap do |m|
244
246
  if settings[:bcc]
245
247
  m.bcc = BccSettings.new(**settings[:bcc])
@@ -1,3 +1,3 @@
1
1
  module SendGridActionMailer
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.1.1'.freeze
3
3
  end
@@ -772,6 +772,45 @@ module SendGridActionMailer
772
772
  expect(response).to respond_to(:to_json)
773
773
  end
774
774
  end
775
+
776
+ context 'when mail_settings are present' do
777
+ it 'should apply mail_settings to request body' do
778
+ m = DeliveryMethod.new(api_key: 'key', return_response: true, mail_settings: { sandbox_mode: {enable: true }})
779
+ m.deliver!(mail)
780
+ expect(client.sent_mail['mail_settings']).to eq("sandbox_mode" => {"enable" => true })
781
+ end
782
+
783
+ context 'when mail has mail_settings set' do
784
+ before { mail['mail_settings'] = { spam_check: { enable: true } } }
785
+
786
+ it 'should combine local mail_settings with global settings' do
787
+ m = DeliveryMethod.new(api_key: 'key', return_response: true, mail_settings: { sandbox_mode: {enable: true }})
788
+ m.deliver!(mail)
789
+ expect(client.sent_mail['mail_settings']).to eq(
790
+ "sandbox_mode" => {"enable" => true },
791
+ "spam_check" => {"enable" => true },
792
+ )
793
+ end
794
+ end
795
+
796
+ context 'when mail contains the same setting as global settings' do
797
+ before do
798
+ mail['mail_settings'] = {
799
+ sandbox_mode: { enable: false },
800
+ spam_check: { enable: true }
801
+ }
802
+ end
803
+
804
+ it 'should apply local mail_settings on top of global settings' do
805
+ m = DeliveryMethod.new(api_key: 'key', return_response: true, mail_settings: { sandbox_mode: {enable: true }})
806
+ m.deliver!(mail)
807
+ expect(client.sent_mail['mail_settings']).to eq(
808
+ "sandbox_mode" => {"enable" => false },
809
+ "spam_check" => {"enable" => true },
810
+ )
811
+ end
812
+ end
813
+ end
775
814
  end
776
815
  end
777
816
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendgrid-actionmailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eddie Zaneski
8
8
  - Kristján Pétursson
9
9
  - Nick Muerdter
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-08-03 00:00:00.000000000 Z
13
+ date: 2020-11-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mail
@@ -140,7 +140,7 @@ homepage: https://github.com/eddiezane/sendgrid-actionmailer
140
140
  licenses:
141
141
  - MIT
142
142
  metadata: {}
143
- post_install_message:
143
+ post_install_message:
144
144
  rdoc_options: []
145
145
  require_paths:
146
146
  - lib
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubygems_version: 3.0.6
159
- signing_key:
159
+ signing_key:
160
160
  specification_version: 4
161
161
  summary: SendGrid support for ActionMailer.
162
162
  test_files: