panthoot 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +11 -0
- data/LICENSE +22 -0
- data/README.textile +44 -0
- data/Rakefile +2 -0
- data/config.ru +7 -0
- data/config/routes.rb +3 -0
- data/lib/panthoot.rb +23 -0
- data/lib/panthoot/app.rb +5 -0
- data/lib/panthoot/data.rb +10 -0
- data/lib/panthoot/data/base.rb +3 -0
- data/lib/panthoot/data/campaign_sending_status.rb +3 -0
- data/lib/panthoot/data/cleaned_email.rb +3 -0
- data/lib/panthoot/data/email_address_change.rb +3 -0
- data/lib/panthoot/data/profile.rb +3 -0
- data/lib/panthoot/data/subscription.rb +3 -0
- data/lib/panthoot/data/unsubscription.rb +3 -0
- data/lib/panthoot/engine.rb +3 -0
- data/lib/panthoot/translator.rb +48 -0
- data/lib/panthoot/version.rb +3 -0
- data/panthoot.gemspec +22 -0
- data/spec/internal/app/listeners/mail_chimp_listener.rb +3 -0
- data/spec/internal/config/initializers/panthoot.rb +3 -0
- data/spec/internal/config/routes.rb +3 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/requests/notifications_spec.rb +216 -0
- data/spec/spec_helper.rb +8 -0
- metadata +114 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
gem 'combustion',
|
4
|
+
:git => 'git://github.com/freelancing-god/combustion',
|
5
|
+
:ref => 'd7a6836269a8fb528bc3721e9b8c06b5a62ef3cc'
|
6
|
+
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
gem 'grape',
|
10
|
+
:git => 'git://github.com/intridea/grape.git',
|
11
|
+
:ref => '212c96cdfb253a59bc93790808c568e559d04468'
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Pat Allan and Inspire9.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
h1. Pant-hoot
|
2
|
+
|
3
|
+
bq. The pant-hoot is a vocalization of chimpanzees that begins with breathy, low-pitched hoots that makes a transition into a series of quicker, higher-pitched in-and-out pants building to a loud climax.
|
4
|
+
|
5
|
+
Pant-hoot is a gem that provides the API MailChimp expects for its webhooks, and then passes on those notifications to you in a sensible, Ruby-infused manner. If you're using Rails, then it functions as a Rails Engine. Otherwise, you'll have a Rack app to use as you see fit.
|
6
|
+
|
7
|
+
h2. Usage
|
8
|
+
|
9
|
+
Add the gem to your Gemfile:
|
10
|
+
|
11
|
+
<pre><code>gem 'panthoot', '~> 0.0.1'</code></pre>
|
12
|
+
|
13
|
+
If you're using Rails, this will automatically add a route at @/panthoot/hooks@ to capture messages from MailChimp. Otherwise, mount the Rack app @Panthoot::App@ to wherever you like. Make sure you add that URL to your MailChimp account settings, otherwise this will all be for naught.
|
14
|
+
|
15
|
+
The next step is to tell Panthoot that you want to be informed whenever MailChimp sends something your way. In Rails, stick the configuration in an initializer, but for Rack just make sure it's set as part of your app load process.
|
16
|
+
|
17
|
+
<pre><code>Panthoot.configure do |config|
|
18
|
+
config.listener = MailChimpListener
|
19
|
+
end</code></pre>
|
20
|
+
|
21
|
+
The listener class is something you'll need to define. You can call this class whatever you like, but it should respond to the following methods:
|
22
|
+
|
23
|
+
* #subscribe(subscription, fired_at)
|
24
|
+
* #unsubscribe(unsubscription, fired_at)
|
25
|
+
* #profile_update(update, fired_at)
|
26
|
+
* #email_address_change(change, fired_at)
|
27
|
+
* #email_cleaned(clean, fired_at)
|
28
|
+
* #campaign_sending_status(status, fired_at)
|
29
|
+
|
30
|
+
As you can probably guess from the method signatures, each notification will provide an object with all the data from MailChimp, plus the time the notification was fired. When the methods get called, you get to do your thing with the data provided. Have fun!
|
31
|
+
|
32
|
+
h2. Contributing
|
33
|
+
|
34
|
+
# Fork it
|
35
|
+
# Create your feature branch (@git checkout -b my-new-feature@)
|
36
|
+
# Commit your changes (@git commit -am 'Added some feature'@)
|
37
|
+
# Push to the branch (@git push origin my-new-feature@)
|
38
|
+
# Create new Pull Request
|
39
|
+
|
40
|
+
Pull requests without tests may be rejected purely on that basis. You've been warned.
|
41
|
+
|
42
|
+
h2. Credits
|
43
|
+
|
44
|
+
Copyright (c) 2012, Panthoot is developed and maintained by Pat Allan on behalf of "Inspire9":http://inspire9.com, and is released under the open MIT Licence.
|
data/Rakefile
ADDED
data/config.ru
ADDED
data/config/routes.rb
ADDED
data/lib/panthoot.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'grape'
|
2
|
+
require 'hashie'
|
3
|
+
|
4
|
+
module Panthoot
|
5
|
+
def self.configure
|
6
|
+
yield self
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.listener
|
10
|
+
@listener
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.listener=(listener)
|
14
|
+
@listener = listener
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'panthoot/app'
|
19
|
+
require 'panthoot/data'
|
20
|
+
require 'panthoot/translator'
|
21
|
+
require 'panthoot/version'
|
22
|
+
|
23
|
+
require 'panthoot/engine' if defined?(Rails)
|
data/lib/panthoot/app.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
module Panthoot::Data
|
2
|
+
end
|
3
|
+
|
4
|
+
require 'panthoot/data/base'
|
5
|
+
require 'panthoot/data/campaign_sending_status'
|
6
|
+
require 'panthoot/data/cleaned_email'
|
7
|
+
require 'panthoot/data/email_address_change'
|
8
|
+
require 'panthoot/data/profile'
|
9
|
+
require 'panthoot/data/subscription'
|
10
|
+
require 'panthoot/data/unsubscription'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Panthoot::Translator
|
2
|
+
DATA_CLASSES = {
|
3
|
+
'subscribe' => Panthoot::Data::Subscription,
|
4
|
+
'unsubscribe' => Panthoot::Data::Unsubscription,
|
5
|
+
'profile' => Panthoot::Data::Profile,
|
6
|
+
'upemail' => Panthoot::Data::EmailAddressChange,
|
7
|
+
'cleaned' => Panthoot::Data::CleanedEmail,
|
8
|
+
'campaign' => Panthoot::Data::CampaignSendingStatus
|
9
|
+
}
|
10
|
+
|
11
|
+
LISTENER_METHODS = {
|
12
|
+
'subscribe' => 'subscribe', 'unsubscribe' => 'unsubscribe',
|
13
|
+
'profile' => 'profile_update', 'upemail' => 'email_address_change',
|
14
|
+
'cleaned' => 'email_cleaned', 'campaign' => 'campaign_sending_status'
|
15
|
+
}
|
16
|
+
|
17
|
+
def self.translate!(params)
|
18
|
+
new(params).translate!
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(params)
|
22
|
+
@params = params
|
23
|
+
end
|
24
|
+
|
25
|
+
def translate!
|
26
|
+
Panthoot.listener.send LISTENER_METHODS[type], translated_object, fired_at
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :params
|
32
|
+
|
33
|
+
def translated_object
|
34
|
+
DATA_CLASSES[type].new data
|
35
|
+
end
|
36
|
+
|
37
|
+
def data
|
38
|
+
params['data']
|
39
|
+
end
|
40
|
+
|
41
|
+
def fired_at
|
42
|
+
Time.zone.parse params['fired_at']
|
43
|
+
end
|
44
|
+
|
45
|
+
def type
|
46
|
+
params['type']
|
47
|
+
end
|
48
|
+
end
|
data/panthoot.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/panthoot/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Pat Allan']
|
6
|
+
gem.email = ['pat@freelancing-gods.com']
|
7
|
+
gem.description = 'Listener for MailChimp callbacks'
|
8
|
+
gem.summary = 'Provides a listener for MailChimp callbacks for Rack/Rails apps'
|
9
|
+
gem.homepage = 'https://github.com/inspire9/panthoot'
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = 'panthoot'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = Panthoot::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'hashie', '1.2.0'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rails', '3.2.2'
|
21
|
+
gem.add_development_dependency 'rspec-rails', '2.10.1'
|
22
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
File without changes
|
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'MailChimp Webhook Notifications' do
|
4
|
+
let(:fired_at) { Time.zone.local(2009, 3, 26, 21, 35, 57) }
|
5
|
+
|
6
|
+
describe 'subscribes' do
|
7
|
+
it "sends the listener a subscription object" do
|
8
|
+
MailChimpListener.should_receive(:subscribe) do |subscription, fired_at|
|
9
|
+
subscription.id.should == '8a25ff1d98'
|
10
|
+
subscription.list_id.should == 'a6b5da1054'
|
11
|
+
subscription.email.should == 'api@mailchimp.com'
|
12
|
+
subscription.email_type.should == 'html'
|
13
|
+
subscription.ip_opt.should == '10.20.10.30'
|
14
|
+
subscription.ip_signup.should == '10.20.10.30'
|
15
|
+
subscription.merges.should == {
|
16
|
+
'EMAIL' => 'api@mailchimp.com',
|
17
|
+
'FNAME' => 'MailChimp',
|
18
|
+
'LNAME' => 'API'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
post '/panthoot/hooks', 'type' => 'subscribe',
|
23
|
+
'fired_at' => fired_at.to_s(:db), 'data[id]' => '8a25ff1d98',
|
24
|
+
'data[list_id]' => 'a6b5da1054', 'data[email]' => 'api@mailchimp.com',
|
25
|
+
'data[email_type]' => 'html',
|
26
|
+
'data[merges][EMAIL]' => 'api@mailchimp.com',
|
27
|
+
'data[merges][FNAME]' => 'MailChimp',
|
28
|
+
'data[merges][LNAME]' => 'API', 'data[ip_opt]' => '10.20.10.30',
|
29
|
+
'data[ip_signup]' => '10.20.10.30'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sends the listener the fired at timestamp" do
|
33
|
+
MailChimpListener.should_receive(:subscribe).with(anything, fired_at)
|
34
|
+
|
35
|
+
post '/panthoot/hooks', 'type' => 'subscribe',
|
36
|
+
'fired_at' => fired_at.to_s(:db), 'data[id]' => '8a25ff1d98',
|
37
|
+
'data[list_id]' => 'a6b5da1054', 'data[email]' => 'api@mailchimp.com',
|
38
|
+
'data[email_type]' => 'html',
|
39
|
+
'data[merges][EMAIL]' => 'api@mailchimp.com',
|
40
|
+
'data[merges][FNAME]' => 'MailChimp',
|
41
|
+
'data[merges][LNAME]' => 'API', 'data[ip_opt]' => '10.20.10.30',
|
42
|
+
'data[ip_signup]' => '10.20.10.30'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'unsubscribes' do
|
47
|
+
it "sends the listener an unsubscription object" do
|
48
|
+
MailChimpListener.should_receive(:unsubscribe) do |unsubscription, fired_at|
|
49
|
+
unsubscription.action.should == 'unsub'
|
50
|
+
unsubscription.reason.should == 'manual'
|
51
|
+
unsubscription.id.should == '8a25ff1d98'
|
52
|
+
unsubscription.list_id.should == 'a6b5da1054'
|
53
|
+
unsubscription.email.should == 'api+unsub@mailchimp.com'
|
54
|
+
unsubscription.email_type.should == 'html'
|
55
|
+
unsubscription.ip_opt.should == '10.20.10.30'
|
56
|
+
unsubscription.campaign_id.should == 'cb398d21d2'
|
57
|
+
unsubscription.merges.should == {
|
58
|
+
'EMAIL' => 'api@mailchimp.com',
|
59
|
+
'FNAME' => 'MailChimp',
|
60
|
+
'LNAME' => 'API',
|
61
|
+
'INTERESTS' => 'Group1,Group2'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
post '/panthoot/hooks', 'type' => 'unsubscribe',
|
66
|
+
'fired_at' => fired_at.to_s(:db), 'data[action]' => 'unsub',
|
67
|
+
'data[reason]' => 'manual', 'data[id]' => '8a25ff1d98',
|
68
|
+
'data[list_id]' => 'a6b5da1054', 'data[email]' => 'api@mailchimp.com',
|
69
|
+
'data[email_type]' => 'html',
|
70
|
+
'data[merges][EMAIL]' => 'api@mailchimp.com',
|
71
|
+
'data[merges][FNAME]' => 'MailChimp',
|
72
|
+
'data[merges][LNAME]' => 'API',
|
73
|
+
'data[merges][INTERESTS]' => 'Group1,Group2',
|
74
|
+
'data[ip_opt]' => '10.20.10.30',
|
75
|
+
'data[campaign_id]' => 'cb398d21d2'
|
76
|
+
end
|
77
|
+
|
78
|
+
it "sends the listener the fired at timestamp" do
|
79
|
+
MailChimpListener.should_receive(:unsubscribe).with(anything, fired_at)
|
80
|
+
|
81
|
+
post '/panthoot/hooks', 'type' => 'unsubscribe',
|
82
|
+
'fired_at' => fired_at.to_s(:db), 'data[action]' => 'unsub',
|
83
|
+
'data[reason]' => 'manual', 'data[id]' => '8a25ff1d98',
|
84
|
+
'data[list_id]' => 'a6b5da1054', 'data[email]' => 'api@mailchimp.com',
|
85
|
+
'data[email_type]' => 'html',
|
86
|
+
'data[merges][EMAIL]' => 'api@mailchimp.com',
|
87
|
+
'data[merges][FNAME]' => 'MailChimp',
|
88
|
+
'data[merges][LNAME]' => 'API',
|
89
|
+
'data[merges][INTERESTS]' => 'Group1,Group2',
|
90
|
+
'data[ip_opt]' => '10.20.10.30',
|
91
|
+
'data[campaign_id]' => 'cb398d21d2'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe 'profile updates' do
|
96
|
+
it "sends the listener a profile object" do
|
97
|
+
MailChimpListener.should_receive(:profile_update) do |profile, fired_at|
|
98
|
+
profile.id.should == '8a25ff1d98'
|
99
|
+
profile.list_id.should == 'a6b5da1054'
|
100
|
+
profile.email.should == 'api+unsub@mailchimp.com'
|
101
|
+
profile.email_type.should == 'html'
|
102
|
+
profile.ip_opt.should == '10.20.10.30'
|
103
|
+
profile.merges.should == {
|
104
|
+
'EMAIL' => 'api@mailchimp.com',
|
105
|
+
'FNAME' => 'MailChimp',
|
106
|
+
'LNAME' => 'API',
|
107
|
+
'INTERESTS' => 'Group1,Group2'
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
post '/panthoot/hooks', 'type' => 'profile',
|
112
|
+
'fired_at' => fired_at.to_s(:db), 'data[id]' => '8a25ff1d98',
|
113
|
+
'data[list_id]' => 'a6b5da1054', 'data[email]' => 'api@mailchimp.com',
|
114
|
+
'data[email_type]' => 'html',
|
115
|
+
'data[merges][EMAIL]' => 'api@mailchimp.com',
|
116
|
+
'data[merges][FNAME]' => 'MailChimp',
|
117
|
+
'data[merges][LNAME]' => 'API',
|
118
|
+
'data[merges][INTERESTS]' => 'Group1,Group2',
|
119
|
+
'data[ip_opt]' => '10.20.10.30'
|
120
|
+
end
|
121
|
+
|
122
|
+
it "sends the listener the fired at timestamp" do
|
123
|
+
MailChimpListener.should_receive(:profile_update).with(anything, fired_at)
|
124
|
+
|
125
|
+
post '/panthoot/hooks', 'type' => 'profile',
|
126
|
+
'fired_at' => fired_at.to_s(:db), 'data[id]' => '8a25ff1d98',
|
127
|
+
'data[list_id]' => 'a6b5da1054', 'data[email]' => 'api@mailchimp.com',
|
128
|
+
'data[email_type]' => 'html',
|
129
|
+
'data[merges][EMAIL]' => 'api@mailchimp.com',
|
130
|
+
'data[merges][FNAME]' => 'MailChimp',
|
131
|
+
'data[merges][LNAME]' => 'API',
|
132
|
+
'data[merges][INTERESTS]' => 'Group1,Group2',
|
133
|
+
'data[ip_opt]' => '10.20.10.30'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe 'email address changes' do
|
138
|
+
it "sends the listener an email address change object" do
|
139
|
+
MailChimpListener.should_receive(:email_address_change) do |email_change, fired_at|
|
140
|
+
email_change.list_id.should == 'a6b5da1054'
|
141
|
+
email_change.new_id.should == '51da8c3259'
|
142
|
+
email_change.new_email.should == 'api+new@mailchimp.com'
|
143
|
+
email_change.old_email.should == 'api+old@mailchimp.com'
|
144
|
+
end
|
145
|
+
|
146
|
+
post '/panthoot/hooks', 'type' => 'upemail',
|
147
|
+
'fired_at' => fired_at.to_s(:db), 'data[list_id]' => 'a6b5da1054',
|
148
|
+
'data[new_id]' => '51da8c3259',
|
149
|
+
'data[new_email]' => 'api+new@mailchimp.com',
|
150
|
+
'data[old_email]' => 'api+old@mailchimp.com'
|
151
|
+
end
|
152
|
+
|
153
|
+
it "sends the listener the fired at timestamp" do
|
154
|
+
MailChimpListener.should_receive(:email_address_change).
|
155
|
+
with(anything, fired_at)
|
156
|
+
|
157
|
+
post '/panthoot/hooks', 'type' => 'upemail',
|
158
|
+
'fired_at' => fired_at.to_s(:db), 'data[list_id]' => 'a6b5da1054',
|
159
|
+
'data[new_id]' => '51da8c3259',
|
160
|
+
'data[new_email]' => 'api+new@mailchimp.com',
|
161
|
+
'data[old_email]' => 'api+old@mailchimp.com'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe 'cleaned emails' do
|
166
|
+
it "sends the listener a cleaned email object" do
|
167
|
+
MailChimpListener.should_receive(:email_cleaned) do |cleaned, fired_at|
|
168
|
+
cleaned.list_id.should == 'a6b5da1054'
|
169
|
+
cleaned.campaign_id.should == '4fjk2ma9xd'
|
170
|
+
cleaned.reason.should == 'hard'
|
171
|
+
cleaned.email.should == 'api+cleaned@mailchimp.com'
|
172
|
+
end
|
173
|
+
|
174
|
+
post '/panthoot/hooks', 'type' => 'cleaned',
|
175
|
+
'fired_at' => fired_at.to_s(:db), 'data[list_id]' => 'a6b5da1054',
|
176
|
+
'data[campaign_id]' => '4fjk2ma9xd', 'data[reason]' => 'hard',
|
177
|
+
'data[email]' => 'api+cleaned@mailchimp.com'
|
178
|
+
end
|
179
|
+
|
180
|
+
it "sends the listener the fired at timestamp" do
|
181
|
+
MailChimpListener.should_receive(:email_cleaned).with(anything, fired_at)
|
182
|
+
|
183
|
+
post '/panthoot/hooks', 'type' => 'cleaned',
|
184
|
+
'fired_at' => fired_at.to_s(:db), 'data[list_id]' => 'a6b5da1054',
|
185
|
+
'data[campaign_id]' => '4fjk2ma9xd', 'data[reason]' => 'hard',
|
186
|
+
'data[email]' => 'api+cleaned@mailchimp.com'
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe 'cleaned emails' do
|
191
|
+
it "sends the listener a campaign sending status object" do
|
192
|
+
MailChimpListener.should_receive(:campaign_sending_status) do |status, fired_at|
|
193
|
+
status.id.should == '5aa2102003'
|
194
|
+
status.subject.should == 'Test Campaign Subject'
|
195
|
+
status.status.should == 'sent'
|
196
|
+
status.reason.should == ''
|
197
|
+
status.list_id.should == 'a6b5da1054'
|
198
|
+
end
|
199
|
+
|
200
|
+
post '/panthoot/hooks', 'type' => 'campaign',
|
201
|
+
'fired_at' => fired_at.to_s(:db), 'data[list_id]' => 'a6b5da1054',
|
202
|
+
'data[subject]' => 'Test Campaign Subject', 'data[status]' => 'sent',
|
203
|
+
'data[reason]' => '', 'data[id]' => '5aa2102003'
|
204
|
+
end
|
205
|
+
|
206
|
+
it "sends the listener the fired at timestamp" do
|
207
|
+
MailChimpListener.should_receive(:campaign_sending_status).
|
208
|
+
with(anything, fired_at)
|
209
|
+
|
210
|
+
post '/panthoot/hooks', 'type' => 'campaign',
|
211
|
+
'fired_at' => fired_at.to_s(:db), 'data[list_id]' => 'a6b5da1054',
|
212
|
+
'data[subject]' => 'Test Campaign Subject', 'data[status]' => 'sent',
|
213
|
+
'data[reason]' => '', 'data[id]' => '5aa2102003'
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: panthoot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Pat Allan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hashie
|
16
|
+
requirement: &70232992118500 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70232992118500
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &70232992110760 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.2.2
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70232992110760
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-rails
|
38
|
+
requirement: &70232992106780 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.10.1
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70232992106780
|
47
|
+
description: Listener for MailChimp callbacks
|
48
|
+
email:
|
49
|
+
- pat@freelancing-gods.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE
|
57
|
+
- README.textile
|
58
|
+
- Rakefile
|
59
|
+
- config.ru
|
60
|
+
- config/routes.rb
|
61
|
+
- lib/panthoot.rb
|
62
|
+
- lib/panthoot/app.rb
|
63
|
+
- lib/panthoot/data.rb
|
64
|
+
- lib/panthoot/data/base.rb
|
65
|
+
- lib/panthoot/data/campaign_sending_status.rb
|
66
|
+
- lib/panthoot/data/cleaned_email.rb
|
67
|
+
- lib/panthoot/data/email_address_change.rb
|
68
|
+
- lib/panthoot/data/profile.rb
|
69
|
+
- lib/panthoot/data/subscription.rb
|
70
|
+
- lib/panthoot/data/unsubscription.rb
|
71
|
+
- lib/panthoot/engine.rb
|
72
|
+
- lib/panthoot/translator.rb
|
73
|
+
- lib/panthoot/version.rb
|
74
|
+
- panthoot.gemspec
|
75
|
+
- spec/internal/app/listeners/mail_chimp_listener.rb
|
76
|
+
- spec/internal/config/initializers/panthoot.rb
|
77
|
+
- spec/internal/config/routes.rb
|
78
|
+
- spec/internal/log/.gitignore
|
79
|
+
- spec/internal/public/favicon.ico
|
80
|
+
- spec/requests/notifications_spec.rb
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
homepage: https://github.com/inspire9/panthoot
|
83
|
+
licenses: []
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.8.16
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: Provides a listener for MailChimp callbacks for Rack/Rails apps
|
106
|
+
test_files:
|
107
|
+
- spec/internal/app/listeners/mail_chimp_listener.rb
|
108
|
+
- spec/internal/config/initializers/panthoot.rb
|
109
|
+
- spec/internal/config/routes.rb
|
110
|
+
- spec/internal/log/.gitignore
|
111
|
+
- spec/internal/public/favicon.ico
|
112
|
+
- spec/requests/notifications_spec.rb
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
has_rdoc:
|