sendgrid_events 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/.rvmrc +5 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +141 -0
- data/MIT-LICENSE +20 -0
- data/README.md +33 -0
- data/Rakefile +13 -0
- data/app/controllers/sendgrid_events/sendgrid_events_controller.rb +8 -0
- data/app/models/sendgrid_events/sendgrid_email_record.rb +14 -0
- data/lib/generators/sendgrid_events/install/templates/initializer.rb +5 -0
- data/lib/generators/sendgrid_events/install/templates/routes.rb +2 -0
- data/lib/generators/sendgrid_events/install/templates/sendgrid_events_table.rb +16 -0
- data/lib/generators/sendgrid_events/install_generator.rb +34 -0
- data/lib/sendgrid_events.rb +8 -0
- data/lib/sendgrid_events/action_mailer_override.rb +23 -0
- data/lib/sendgrid_events/configure.rb +23 -0
- data/lib/sendgrid_events/engine.rb +12 -0
- data/lib/sendgrid_events/handlers.rb +3 -0
- data/lib/sendgrid_events/handlers/base.rb +50 -0
- data/lib/sendgrid_events/handlers/bounced.rb +7 -0
- data/lib/sendgrid_events/handlers/clicked.rb +7 -0
- data/lib/sendgrid_events/handlers/deferred.rb +7 -0
- data/lib/sendgrid_events/handlers/delivered.rb +10 -0
- data/lib/sendgrid_events/handlers/dispatch.rb +34 -0
- data/lib/sendgrid_events/handlers/dropped.rb +7 -0
- data/lib/sendgrid_events/handlers/opened.rb +7 -0
- data/lib/sendgrid_events/handlers/processed.rb +7 -0
- data/lib/sendgrid_events/handlers/spam_reported.rb +7 -0
- data/lib/sendgrid_events/handlers/unsubscribed.rb +7 -0
- data/lib/sendgrid_events/receiver.rb +18 -0
- data/lib/sendgrid_events/version.rb +3 -0
- data/script/rails +8 -0
- data/sendgrid_events.gemspec +28 -0
- data/spec/sendgrid_events/handlers/base_spec.rb +47 -0
- data/spec/sendgrid_events/handlers/bounced_spec.rb +31 -0
- data/spec/sendgrid_events/handlers/clicked_spec.rb +31 -0
- data/spec/sendgrid_events/handlers/deferred_spec.rb +31 -0
- data/spec/sendgrid_events/handlers/delivered_spec.rb +31 -0
- data/spec/sendgrid_events/handlers/dispatch_spec.rb +8 -0
- data/spec/sendgrid_events/handlers/dropped_spec.rb +31 -0
- data/spec/sendgrid_events/handlers/opened_spec.rb +31 -0
- data/spec/sendgrid_events/handlers/processed_spec.rb +31 -0
- data/spec/sendgrid_events/handlers/spam_reported_spec.rb +31 -0
- data/spec/sendgrid_events/handlers/unsubscribed_spec.rb +31 -0
- data/spec/sendgrid_events/receiver_spec.rb +32 -0
- data/spec/spec_helper.rb +39 -0
- metadata +272 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module SendgridEvents
|
3
|
+
module Handlers
|
4
|
+
describe SpamReported do
|
5
|
+
subject { SpamReported }
|
6
|
+
it { should respond_to(:handle) }
|
7
|
+
it { should respond_to(:handlee) }
|
8
|
+
let(:event) { {
|
9
|
+
:email => "foo@bar.com",
|
10
|
+
:timestamp => 1322000095,
|
11
|
+
:sendgrid_events_id => '7',
|
12
|
+
:event => "spamreport"
|
13
|
+
} }
|
14
|
+
|
15
|
+
it "updates event, but doesn't call handler without one set" do
|
16
|
+
subject.should_receive(:find_and_update_event).with(event).once
|
17
|
+
subject.should_receive(:handler).never
|
18
|
+
subject.handle(event)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "updates event, but doesn't call handler without one set" do
|
22
|
+
subject.handler do
|
23
|
+
true
|
24
|
+
end
|
25
|
+
subject.stub(:find_and_update_event => true)
|
26
|
+
subject.should_receive(:handler).once
|
27
|
+
subject.handle(event)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module SendgridEvents
|
3
|
+
module Handlers
|
4
|
+
describe Unsubscribed do
|
5
|
+
subject { Unsubscribed }
|
6
|
+
it { should respond_to(:handle) }
|
7
|
+
it { should respond_to(:handlee) }
|
8
|
+
let(:event) { {
|
9
|
+
:email => "foo@bar.com",
|
10
|
+
:timestamp => 1322000095,
|
11
|
+
:sendgrid_events_id => '7',
|
12
|
+
:event => "unsubscribe"
|
13
|
+
} }
|
14
|
+
|
15
|
+
it "updates event, but doesn't call handler without one set" do
|
16
|
+
subject.should_receive(:find_and_update_event).with(event).once
|
17
|
+
subject.should_receive(:handler).never
|
18
|
+
subject.handle(event)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "updates event, but doesn't call handler without one set" do
|
22
|
+
subject.handler do
|
23
|
+
true
|
24
|
+
end
|
25
|
+
subject.stub(:find_and_update_event => true)
|
26
|
+
subject.should_receive(:handler).once
|
27
|
+
subject.handle(event)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module SendgridEvents
|
3
|
+
describe Receiver do
|
4
|
+
subject { Receiver }
|
5
|
+
it { should respond_to(:receive) }
|
6
|
+
it { should respond_to(:extract_events_and_clean) }
|
7
|
+
|
8
|
+
let(:params) {
|
9
|
+
{"{\"email\":\"foo@bar.com\",\"timestamp\":1322000095,\"sendgrid_events_id\":\"7\",\"event\":\"delivered\"}\n{\"email\":\"foo@bar.com\",\"timestamp\":1322000096,\"sendgrid_events_id\":\"4\",\"event\":\"delivered\"}" => nil}
|
10
|
+
}
|
11
|
+
|
12
|
+
it "sends the poorly composed params to be cleaned then handles" do
|
13
|
+
Handlers::Base.should_receive(:choose_and_handle).exactly(2).times
|
14
|
+
subject.receive params
|
15
|
+
end
|
16
|
+
|
17
|
+
it "extracts JSON objects" do
|
18
|
+
subject.extract_events_and_clean(params).should == [{
|
19
|
+
:email => "foo@bar.com",
|
20
|
+
:timestamp => 1322000095,
|
21
|
+
:sendgrid_events_id => '7',
|
22
|
+
:event => "delivered"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
:email => "foo@bar.com",
|
26
|
+
:timestamp => 1322000096,
|
27
|
+
:sendgrid_events_id => "4",
|
28
|
+
:event => "delivered"
|
29
|
+
}]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'action_mailer'
|
8
|
+
require 'rails'
|
9
|
+
require 'sqlite3'
|
10
|
+
require 'active_record'
|
11
|
+
require 'enumerated_field'
|
12
|
+
|
13
|
+
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
|
14
|
+
ActiveRecord::Schema.define do
|
15
|
+
create_table :sendgrid_email_records, :force => true do |t|
|
16
|
+
t.string :status
|
17
|
+
t.string :to
|
18
|
+
t.string :from
|
19
|
+
t.string :subject
|
20
|
+
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Dir.glob(File.expand_path('../../app/models/**/*.rb', __FILE__)).each { |file| require file }
|
26
|
+
require 'sendgrid_events'
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
|
30
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
31
|
+
config.run_all_when_everything_filtered = true
|
32
|
+
config.filter_run :focus
|
33
|
+
|
34
|
+
# Run specs in random order to surface order dependencies. If you find an
|
35
|
+
# order dependency and want to debug it, you can fix the order by providing
|
36
|
+
# the seed, which is printed after each run.
|
37
|
+
# --seed 1234
|
38
|
+
config.order = 'random'
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,272 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sendgrid_events
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jon Phenow
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: awesome_print
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec-rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.6'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.6'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: capybara
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 3.0.15
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 3.0.15
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: factory_girl_rails
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '1.7'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.7'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: sqlite3
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rails
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 3.0.15
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 3.0.15
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: sendgrid
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: enumerated_field
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
description: ''
|
175
|
+
email:
|
176
|
+
- jon.phenow@tstmedia.com
|
177
|
+
executables: []
|
178
|
+
extensions: []
|
179
|
+
extra_rdoc_files: []
|
180
|
+
files:
|
181
|
+
- .gitignore
|
182
|
+
- .rspec
|
183
|
+
- .rvmrc
|
184
|
+
- .travis.yml
|
185
|
+
- Gemfile
|
186
|
+
- Gemfile.lock
|
187
|
+
- MIT-LICENSE
|
188
|
+
- README.md
|
189
|
+
- Rakefile
|
190
|
+
- app/controllers/sendgrid_events/sendgrid_events_controller.rb
|
191
|
+
- app/models/sendgrid_events/sendgrid_email_record.rb
|
192
|
+
- lib/generators/sendgrid_events/install/templates/initializer.rb
|
193
|
+
- lib/generators/sendgrid_events/install/templates/routes.rb
|
194
|
+
- lib/generators/sendgrid_events/install/templates/sendgrid_events_table.rb
|
195
|
+
- lib/generators/sendgrid_events/install_generator.rb
|
196
|
+
- lib/sendgrid_events.rb
|
197
|
+
- lib/sendgrid_events/action_mailer_override.rb
|
198
|
+
- lib/sendgrid_events/configure.rb
|
199
|
+
- lib/sendgrid_events/engine.rb
|
200
|
+
- lib/sendgrid_events/handlers.rb
|
201
|
+
- lib/sendgrid_events/handlers/base.rb
|
202
|
+
- lib/sendgrid_events/handlers/bounced.rb
|
203
|
+
- lib/sendgrid_events/handlers/clicked.rb
|
204
|
+
- lib/sendgrid_events/handlers/deferred.rb
|
205
|
+
- lib/sendgrid_events/handlers/delivered.rb
|
206
|
+
- lib/sendgrid_events/handlers/dispatch.rb
|
207
|
+
- lib/sendgrid_events/handlers/dropped.rb
|
208
|
+
- lib/sendgrid_events/handlers/opened.rb
|
209
|
+
- lib/sendgrid_events/handlers/processed.rb
|
210
|
+
- lib/sendgrid_events/handlers/spam_reported.rb
|
211
|
+
- lib/sendgrid_events/handlers/unsubscribed.rb
|
212
|
+
- lib/sendgrid_events/receiver.rb
|
213
|
+
- lib/sendgrid_events/version.rb
|
214
|
+
- script/rails
|
215
|
+
- sendgrid_events.gemspec
|
216
|
+
- spec/sendgrid_events/handlers/base_spec.rb
|
217
|
+
- spec/sendgrid_events/handlers/bounced_spec.rb
|
218
|
+
- spec/sendgrid_events/handlers/clicked_spec.rb
|
219
|
+
- spec/sendgrid_events/handlers/deferred_spec.rb
|
220
|
+
- spec/sendgrid_events/handlers/delivered_spec.rb
|
221
|
+
- spec/sendgrid_events/handlers/dispatch_spec.rb
|
222
|
+
- spec/sendgrid_events/handlers/dropped_spec.rb
|
223
|
+
- spec/sendgrid_events/handlers/opened_spec.rb
|
224
|
+
- spec/sendgrid_events/handlers/processed_spec.rb
|
225
|
+
- spec/sendgrid_events/handlers/spam_reported_spec.rb
|
226
|
+
- spec/sendgrid_events/handlers/unsubscribed_spec.rb
|
227
|
+
- spec/sendgrid_events/receiver_spec.rb
|
228
|
+
- spec/spec_helper.rb
|
229
|
+
homepage: ''
|
230
|
+
licenses: []
|
231
|
+
post_install_message:
|
232
|
+
rdoc_options: []
|
233
|
+
require_paths:
|
234
|
+
- lib
|
235
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
236
|
+
none: false
|
237
|
+
requirements:
|
238
|
+
- - ! '>='
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: '0'
|
241
|
+
segments:
|
242
|
+
- 0
|
243
|
+
hash: 3793329407412117671
|
244
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
245
|
+
none: false
|
246
|
+
requirements:
|
247
|
+
- - ! '>='
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: '0'
|
250
|
+
segments:
|
251
|
+
- 0
|
252
|
+
hash: 3793329407412117671
|
253
|
+
requirements: []
|
254
|
+
rubyforge_project:
|
255
|
+
rubygems_version: 1.8.24
|
256
|
+
signing_key:
|
257
|
+
specification_version: 3
|
258
|
+
summary: ''
|
259
|
+
test_files:
|
260
|
+
- spec/sendgrid_events/handlers/base_spec.rb
|
261
|
+
- spec/sendgrid_events/handlers/bounced_spec.rb
|
262
|
+
- spec/sendgrid_events/handlers/clicked_spec.rb
|
263
|
+
- spec/sendgrid_events/handlers/deferred_spec.rb
|
264
|
+
- spec/sendgrid_events/handlers/delivered_spec.rb
|
265
|
+
- spec/sendgrid_events/handlers/dispatch_spec.rb
|
266
|
+
- spec/sendgrid_events/handlers/dropped_spec.rb
|
267
|
+
- spec/sendgrid_events/handlers/opened_spec.rb
|
268
|
+
- spec/sendgrid_events/handlers/processed_spec.rb
|
269
|
+
- spec/sendgrid_events/handlers/spam_reported_spec.rb
|
270
|
+
- spec/sendgrid_events/handlers/unsubscribed_spec.rb
|
271
|
+
- spec/sendgrid_events/receiver_spec.rb
|
272
|
+
- spec/spec_helper.rb
|