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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTExNDgxYjlhYjc1OGVmZTQ1MjY3M2I5NzAxN2NlZDkzNzkzZTEyZA==
4
+ NTgwZjM2YmEzYjQ1ZTM4MDhiNTM2ZjYyNzI3ODM3OWY0ZjA2Y2JlZg==
5
5
  data.tar.gz: !binary |-
6
- MDBhOGVlYThlZmIzNTIyZWQ5YTMzMDBhZGZiODc1YTQ0ODk2ODM1MA==
6
+ NzVlOGE4OTdmODVlNGQ0ODcxOGFlMWM4M2QxNTczNDgyMWQxMGVjOA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTVhZjZhZjdjOWNkNjk4NjJiYjY2OTQ0ZTlmZGQ2OGJmNTIwMDhmODE1Yzlh
10
- YzQzY2Y0ZmE4OTAzOGNkMWE5N2UxNDkyZWZmNWJkZTY1NjI3NjFiYWM2OTkz
11
- N2Y0MTIzZjI0YzZjNDJlYTFjYTdmOGIyZjg4MDNlYTlmNmQ4NDQ=
9
+ MTRmMTI4NWRjNzJlMWVjODRhOTQwOTc5OTIyNDBjMjRhNjYyYmU3MDM4ZDhj
10
+ ZTk4YTA3NmEwNjI4ZjA3MTE0NWUxNjlhNjQ1NTJhYjFmZGU2ZGQ4NmU4OGVj
11
+ NTU1ZDcxZmE3ZmJkNmU5YjNiY2VkNDA3OTBhZTI2MWJkZTAxYTM=
12
12
  data.tar.gz: !binary |-
13
- YWY0MjYwYmFhNDM4NjkyNzg4NTA4NzcxMTBmMjJhZWZiMzEzYzYxN2M0NWIx
14
- NDZlNDU3ZDVjZGVhNTJkYTFmNTE0NjcwZTJkNDJhNWEwMjhjNzkwYTM2NTA2
15
- ZDUyZjcwOGFlMTAwZGNkMDEzMThjNzUxNTg2NWRmMWU4ZGYwZTU=
13
+ OWE4ZGI1NDc4MDc1OTNlODdiODRiMmU4YTUyNDZkYzNmNGJkY2RjZTVjOGQ1
14
+ NGU0M2Q3ODE1MmU0M2NiZDQ2NThkMDE3NjIxMzc0YzkxZjBjM2YzNzZmYWUw
15
+ ZWEyYzkzZTMwZmJiZTVhYmJmZDgxNWM3YTk5MDJlMWIwODdiMDk=
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Brightbytes::Sendgrid
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/brightbytes-sendgrid.png)](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
 
@@ -4,6 +4,8 @@ module Brightbytes
4
4
  module Sendgrid
5
5
  class Config
6
6
  include Singleton
7
+
8
+ attr_accessor :dummy_recipient
7
9
 
8
10
  # Sendgrid default settings storage
9
11
 
@@ -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: ''})
@@ -1,5 +1,5 @@
1
1
  module Brightbytes
2
2
  module Sendgrid
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -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","http://example.com/u?email=email%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: 'noreply@brightbytes.net',
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 to: 'email@email.com', body: 'Hello!'
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 to: 'email@email.com', body: 'Hello!'
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 to: 'email@email.com', body: 'Hello!'
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 to: 'email@email.com', body: 'Hello!'
34
+ mail body: 'Hello!'
30
35
  end
31
36
 
32
37
 
@@ -1,5 +1,5 @@
1
1
  class StandardMailer < ActionMailer::Base
2
- default from: 'noreply@brightbytes.net',
2
+ default from: 'support@brightbytes.net',
3
3
  subject: 'Clarity'
4
4
 
5
5
  def sendgrid_not_engaged
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
- Brightbytes::Sendgrid.configure do |config|
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.0
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-15 00:00:00.000000000 Z
12
+ date: 2014-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler