brightbytes-sendgrid 0.1.0 → 0.1.1
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 +8 -8
- data/README.md +2 -0
- data/lib/brightbytes/sendgrid/config.rb +2 -0
- data/lib/brightbytes/sendgrid/smtp_api_header.rb +7 -1
- data/lib/brightbytes/sendgrid/version.rb +1 -1
- data/lib/brightbytes/sendgrid.rb +2 -0
- data/spec/brightbytes/sendgrid_mailer_spec.rb +11 -1
- data/spec/mailers/sendgrid_mailer.rb +10 -5
- data/spec/mailers/standard_mailer.rb +1 -1
- data/spec/spec_helper.rb +3 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTgwZjM2YmEzYjQ1ZTM4MDhiNTM2ZjYyNzI3ODM3OWY0ZjA2Y2JlZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzVlOGE4OTdmODVlNGQ0ODcxOGFlMWM4M2QxNTczNDgyMWQxMGVjOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTRmMTI4NWRjNzJlMWVjODRhOTQwOTc5OTIyNDBjMjRhNjYyYmU3MDM4ZDhj
|
10
|
+
ZTk4YTA3NmEwNjI4ZjA3MTE0NWUxNjlhNjQ1NTJhYjFmZGU2ZGQ4NmU4OGVj
|
11
|
+
NTU1ZDcxZmE3ZmJkNmU5YjNiY2VkNDA3OTBhZTI2MWJkZTAxYTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWE4ZGI1NDc4MDc1OTNlODdiODRiMmU4YTUyNDZkYzNmNGJkY2RjZTVjOGQ1
|
14
|
+
NGU0M2Q3ODE1MmU0M2NiZDQ2NThkMDE3NjIxMzc0YzkxZjBjM2YzNzZmYWUw
|
15
|
+
ZWEyYzkzZTMwZmJiZTVhYmJmZDgxNWM3YTk5MDJlMWIwODdiMDk=
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Brightbytes::Sendgrid
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/brightbytes-sendgrid)
|
4
|
+
|
3
5
|
This gem allows for painless integration between ActionMailer and the SendGrid SMTP API.
|
4
6
|
The current scope of this gem is focused around setting configuration options for outgoing email (essentially, setting categories, filters and the settings that can accompany those filters).
|
5
7
|
|
@@ -16,7 +16,8 @@ module Brightbytes
|
|
16
16
|
:filter_setting,
|
17
17
|
:enable,
|
18
18
|
:disable,
|
19
|
-
:ganalytics_options
|
19
|
+
:ganalytics_options,
|
20
|
+
:bcc
|
20
21
|
]
|
21
22
|
|
22
23
|
VALID_FILTERS = [
|
@@ -110,6 +111,11 @@ module Brightbytes
|
|
110
111
|
enable :ganalytics
|
111
112
|
end
|
112
113
|
end
|
114
|
+
|
115
|
+
def bcc(email)
|
116
|
+
filter_setting :bcc, :email, email
|
117
|
+
enable :bcc
|
118
|
+
end
|
113
119
|
|
114
120
|
def to_json
|
115
121
|
JSON.generate(@data, {indent: '', space: ' ', space_before: '', object_nl: '', array_nl: ''})
|
data/lib/brightbytes/sendgrid.rb
CHANGED
@@ -33,6 +33,8 @@ module Brightbytes
|
|
33
33
|
message.instance_variable_set :@sendgrid, sendgrid
|
34
34
|
# Add X-SMTPAPI Header
|
35
35
|
message.header['X-SMTPAPI'] = sendgrid.to_json if sendgrid.data.present?
|
36
|
+
# Add dummy recipient
|
37
|
+
message.header['to'] = Brightbytes::Sendgrid.config.dummy_recipient if sendgrid.recipients.present?
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -20,6 +20,16 @@ describe SendgridMailer do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe "when sendgrid recipients present" do
|
24
|
+
subject(:message) { described_class.dummy_recipient }
|
25
|
+
|
26
|
+
before(:each) { sendgrid_config_setup }
|
27
|
+
|
28
|
+
it 'header should have dummy recipient' do
|
29
|
+
header.should include('To: noreply@brightbytes.net')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
23
33
|
describe "when sendgrid recipients are set" do
|
24
34
|
subject(:message) { described_class.with_recipients }
|
25
35
|
|
@@ -48,7 +58,7 @@ describe SendgridMailer do
|
|
48
58
|
end
|
49
59
|
|
50
60
|
it 'unsubscribe link should be set' do
|
51
|
-
header.should include('"{{unsubscribe_link}}": ["http://example.com/u?email=email1%40email.com&category=unsubscribe","http://example.com/u?email=email2%40email.com&category=unsubscribe"
|
61
|
+
header.should include('"{{unsubscribe_link}}": ["http://example.com/u?email=email1%40email.com&category=unsubscribe","http://example.com/u?email=email2%40email.com&category=unsubscribe"]')
|
52
62
|
end
|
53
63
|
end
|
54
64
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class SendgridMailer < ActionMailer::Base
|
2
|
-
default from: '
|
2
|
+
default from: 'support@brightbytes.net',
|
3
3
|
subject: 'Clarity'
|
4
4
|
|
5
5
|
sendgrid_categories :system
|
@@ -10,23 +10,28 @@ class SendgridMailer < ActionMailer::Base
|
|
10
10
|
|
11
11
|
def new_category
|
12
12
|
sendgrid_categories :new_category
|
13
|
-
mail
|
13
|
+
mail body: 'Hello!'
|
14
|
+
end
|
15
|
+
|
16
|
+
def dummy_recipient
|
17
|
+
sendgrid_add_recipients 'email@email.com'
|
18
|
+
mail body: 'Hello!'
|
14
19
|
end
|
15
20
|
|
16
21
|
def with_recipients
|
17
22
|
sendgrid_recipients 'email1@email.com', 'email2@email.com'
|
18
|
-
mail
|
23
|
+
mail body: 'Hello!'
|
19
24
|
end
|
20
25
|
|
21
26
|
def unsubscribe_not_required
|
22
27
|
sendgrid_recipients 'email1@email.com', 'email2@email.com'
|
23
|
-
mail
|
28
|
+
mail body: 'Hello!'
|
24
29
|
end
|
25
30
|
|
26
31
|
def unsubscribe_required
|
27
32
|
sendgrid_recipients 'email1@email.com', 'email2@email.com'
|
28
33
|
sendgrid_categories :unsubscribe
|
29
|
-
mail
|
34
|
+
mail body: 'Hello!'
|
30
35
|
end
|
31
36
|
|
32
37
|
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,7 @@ Dir["#{File.dirname(__FILE__)}/mailers/*.rb"].each { |f| require f }
|
|
12
12
|
|
13
13
|
def sendgrid_config_setup
|
14
14
|
Brightbytes::Sendgrid.configure do |config|
|
15
|
+
config.dummy_recipient = 'noreply@brightbytes.net'
|
15
16
|
config.unsubscribe_categories :unsubscribe
|
16
17
|
config.unsubscribe_url 'http://example.com/u'
|
17
18
|
end
|
@@ -19,6 +20,7 @@ end
|
|
19
20
|
|
20
21
|
def sendgrid_config_reset
|
21
22
|
Brightbytes::Sendgrid.configure do |config|
|
23
|
+
config.dummy_recipient = nil
|
22
24
|
config.unsubscribe_categories []
|
23
25
|
config.unsubscribe_url nil
|
24
26
|
end
|
@@ -27,10 +29,7 @@ end
|
|
27
29
|
RSpec.configure do |config|
|
28
30
|
|
29
31
|
config.after(:each) do
|
30
|
-
|
31
|
-
config.unsubscribe_categories []
|
32
|
-
config.unsubscribe_url nil
|
33
|
-
end
|
32
|
+
sendgrid_config_reset
|
34
33
|
end
|
35
34
|
|
36
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brightbytes-sendgrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brightbytes Inc.
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|