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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +12 -0
- data/lib/sendgrid_actionmailer.rb +4 -2
- data/lib/sendgrid_actionmailer/version.rb +1 -1
- data/spec/lib/sendgrid_actionmailer_spec.rb +39 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68926bb0db0f0f622282b8429b3df0f86911ca0d72c0146bcaf181966130e290
|
4
|
+
data.tar.gz: '048ca01e72420c6f88be723ada69126d31c831f300b0aa539f8f7d236e3c500f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5999a6b88c2eb27869872a42c0f7300198cb9870f20087a9c38c68909b0bdcd6a960d0adc2eb01dfa39c530ff6eabee727e0ad9762b19294d57be8fd26e598f0
|
7
|
+
data.tar.gz: a26c201d0a9466684796371b82d2cb3d2aaad48efd1fc6a5c1ffd22b410bcdb71203379c498c8ae504653d0a2692206003ac3176ecfd32025e555fb38ebc0d2e
|
data/CHANGELOG.md
CHANGED
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
|
-
|
242
|
-
|
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])
|
@@ -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.
|
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-
|
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:
|