mandrill-rails 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/mandrill-rails.rb +1 -0
- data/lib/mandrill-rails/errors.rb +4 -0
- data/lib/mandrill-rails/version.rb +1 -1
- data/lib/mandrill/web_hook/event_decorator.rb +5 -0
- data/lib/mandrill/web_hook/processor.rb +3 -2
- data/spec/mandrill/web_hook/processor_spec.rb +57 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2JlYTA0MzljZWVlNzAzZTNkNzdiMmJkMjEzNTZhNjkyMjIxNzVhZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGJmZWEwMTI3MzA2MWQ4YjA3MzYwNWIwNTRiMjk4NmI0ODk2M2IxYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2E3N2ZlZDE1MzMyMzM4ODA2M2IyOTVkMzc5NjdiNmVmMDE4Y2UxYWYwOTQ5
|
10
|
+
Mzc2ZGQyNDRiMjBhZGViMWE2MGQ1MGY2OTdhZTA3N2UwMDNhMWI5MGUyM2M5
|
11
|
+
YTdkOWNmNWJmYmVjZTgzMzIyMjBjNTkxN2E4OTk5NmMwOTBiYjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzM3OGI2NDhmOGM3ZDkwYWYxY2Y3ZmQ5YzczYTZlMGMxMDk1ZDU3MWZhZDAy
|
14
|
+
Mjc2ZDU4ZWE5M2I1ZjI2YTM5YmIzYzRiZGQzYWQ2NGViZWI5YWM4N2M3MjEx
|
15
|
+
NGQ1MjQ0ZmI2ZjA0YTFhZWYyMGRiNTAzMDNhYmU5NWUwYmQ1OGM=
|
data/lib/mandrill-rails.rb
CHANGED
@@ -21,12 +21,13 @@ class Mandrill::WebHook::Processor
|
|
21
21
|
mandrill_events.each do |raw_payload|
|
22
22
|
event_payload = wrap_payload(raw_payload)
|
23
23
|
handler = "handle_#{event_payload.event_type}".to_sym
|
24
|
-
if callback_host && callback_host.respond_to?(handler)
|
24
|
+
if callback_host && callback_host.respond_to?(handler, true)
|
25
25
|
callback_host.send(handler,event_payload)
|
26
26
|
elsif self.respond_to?(handler)
|
27
27
|
self.send(handler,event_payload)
|
28
28
|
else
|
29
|
-
|
29
|
+
raise Mandrill::Rails::Errors::MissingEventHandler,
|
30
|
+
"Expected handler method `#{handler}` for event type `#{event_payload.event_type}`"
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
@@ -20,18 +20,67 @@ describe Mandrill::WebHook::Processor do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
context "with callback host" do
|
23
|
-
|
24
|
-
|
25
|
-
host.stub(:handle_inbound)
|
26
|
-
host
|
23
|
+
shared_examples_for 'pass event payload to the handler' do
|
24
|
+
|
27
25
|
end
|
26
|
+
|
27
|
+
let(:callback_host) { callback_host_class.new }
|
28
28
|
let(:processor) { processor_class.new(params,callback_host) }
|
29
29
|
let(:event1) { { "event" => "inbound" } }
|
30
30
|
let(:event2) { { "event" => "inbound" } }
|
31
31
|
let(:params) { { "mandrill_events" => [event1,event2].to_json } }
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
|
33
|
+
context "with handler method as public" do
|
34
|
+
let(:callback_host_class) do
|
35
|
+
Class.new do
|
36
|
+
public
|
37
|
+
|
38
|
+
def handle_inbound; end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should pass event payload to the handler" do
|
43
|
+
callback_host.should_receive(:handle_inbound).twice
|
44
|
+
processor.run!
|
45
|
+
end
|
46
|
+
end
|
47
|
+
context "with handler method as protected" do
|
48
|
+
let(:callback_host_class) do
|
49
|
+
Class.new do
|
50
|
+
protected
|
51
|
+
|
52
|
+
def handle_inbound; end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should pass event payload to the handler" do
|
57
|
+
callback_host.should_receive(:handle_inbound).twice
|
58
|
+
processor.run!
|
59
|
+
end
|
60
|
+
end
|
61
|
+
context "with handler method as private" do
|
62
|
+
let(:callback_host_class) do
|
63
|
+
Class.new do
|
64
|
+
private
|
65
|
+
|
66
|
+
def handle_inbound; end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should pass event payload to the handler" do
|
71
|
+
callback_host.should_receive(:handle_inbound).twice
|
72
|
+
processor.run!
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
context "without handler method" do
|
77
|
+
let(:event1) { { "event" => "inbound" } }
|
78
|
+
let(:event2) { { "event" => "inbound" } }
|
79
|
+
let(:params) { { "mandrill_events" => [event1,event2].to_json } }
|
80
|
+
|
81
|
+
it "raises error on run!" do
|
82
|
+
expect { processor.run! }
|
83
|
+
.to raise_error(Mandrill::Rails::Errors::MissingEventHandler)
|
35
84
|
end
|
36
85
|
end
|
37
86
|
end
|
@@ -79,4 +128,4 @@ describe Mandrill::WebHook::Processor do
|
|
79
128
|
it { should eql(expected_signature) }
|
80
129
|
end
|
81
130
|
|
82
|
-
end
|
131
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mandrill-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Gallagher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- README.rdoc
|
111
111
|
- Rakefile
|
112
112
|
- lib/mandrill-rails.rb
|
113
|
+
- lib/mandrill-rails/errors.rb
|
113
114
|
- lib/mandrill-rails/version.rb
|
114
115
|
- lib/mandrill-rails/web_hook_processor.rb
|
115
116
|
- lib/mandrill/web_hook.rb
|
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
159
|
version: '0'
|
159
160
|
requirements: []
|
160
161
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.4.5
|
162
163
|
signing_key:
|
163
164
|
specification_version: 4
|
164
165
|
summary: Provides webhook processing and event decoration to make using Mandrill with
|