dispatch-rider 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dispatch-rider/notification_services/aws_sns.rb +2 -6
- data/lib/dispatch-rider/notification_services/base.rb +6 -4
- data/lib/dispatch-rider/publisher.rb +1 -1
- data/lib/dispatch-rider/version.rb +1 -1
- data/spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb +17 -0
- data/spec/lib/dispatch-rider/notification_services/base_spec.rb +21 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00791dcc6642fcdce813e92abe1e6112af845b47
|
4
|
+
data.tar.gz: 4db374187ef33441a01b17999c6c4dac5a87b535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89bd9117b23f3ae1a26c0e5b2bd0b5dafaf2509413ac5a06ed12f01b0acdbd29f61b9694a0a3805d92acc4b9c7dfa402b425a263f3fb91055d328d1f4778eb23
|
7
|
+
data.tar.gz: 49054767ae3bc31d56144826a5d41d5b1410045b35020f264815e8e096cd7c9e7a6f2c55cffe446bd2743b8b082e0b37683cdd8dbe3acd3e4d527ea9bf929fb6
|
@@ -16,12 +16,8 @@ module DispatchRider
|
|
16
16
|
Registrars::SnsChannel
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
with_retries(max_retries: 10, rescue: AWS::Errors::MissingCredentialsError) do
|
22
|
-
channel.publish(serialize(options[:message]))
|
23
|
-
end
|
24
|
-
end
|
19
|
+
def publish_to_channel(channel, message:)
|
20
|
+
with_retries(max_retries: 10, rescue: AWS::Errors::MissingCredentialsError) { super }
|
25
21
|
end
|
26
22
|
|
27
23
|
# not really happy with this, but the notification service registrar system is way too rigid to do this cleaner
|
@@ -28,10 +28,8 @@ module DispatchRider
|
|
28
28
|
raise NotImplementedError
|
29
29
|
end
|
30
30
|
|
31
|
-
def publish(
|
32
|
-
channels(
|
33
|
-
channel.publish(serialize(options[:message]))
|
34
|
-
end
|
31
|
+
def publish(to:, message:)
|
32
|
+
channels(to).each { |channel| publish_to_channel channel, message: message }
|
35
33
|
end
|
36
34
|
|
37
35
|
def channels(names)
|
@@ -42,6 +40,10 @@ module DispatchRider
|
|
42
40
|
raise NotImplementedError
|
43
41
|
end
|
44
42
|
|
43
|
+
def publish_to_channel(channel, message:)
|
44
|
+
channel.publish(serialize(message))
|
45
|
+
end
|
46
|
+
|
45
47
|
private
|
46
48
|
|
47
49
|
def serialize(item)
|
@@ -15,6 +15,23 @@ describe DispatchRider::NotificationServices::AwsSns do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
describe "#publish_to_channel" do
|
19
|
+
let(:channel) { double(:channel) }
|
20
|
+
let(:message) { DispatchRider::Message.new(subject: :test_handler, body: { "bar" => "baz" }) }
|
21
|
+
|
22
|
+
# @note: This is tested this way cause you don't really wanna post a message to the actual service.
|
23
|
+
it "publishes the message to the channels" do
|
24
|
+
expect(channel).to receive(:publish).with(kind_of String) { |serialized_message|
|
25
|
+
expect(JSON.parse(serialized_message)).to eq(
|
26
|
+
"subject" => "test_handler",
|
27
|
+
"body" => { "bar" => "baz" }
|
28
|
+
)
|
29
|
+
}
|
30
|
+
|
31
|
+
subject.publish_to_channel(channel, message: message)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
18
35
|
describe "#channel" do
|
19
36
|
before { subject.stub(:channel_registrar).and_return(foo: amazon_resource_name) }
|
20
37
|
|
@@ -39,10 +39,28 @@ describe DispatchRider::NotificationServices::Base do
|
|
39
39
|
subject.notifier.topics['arn:aws:sns:us-east-1:123:PlanOfAttack'] = channel
|
40
40
|
end
|
41
41
|
|
42
|
+
let(:message) { DispatchRider::Message.new(subject: :test_handler, body: { "bar" => "baz" }) }
|
43
|
+
|
44
|
+
it "publishes the message to the channels" do
|
45
|
+
catch(:published) { subject.publish to: :foo, message: message }.should eq("baz")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#publish_to_channel" do
|
50
|
+
let(:channel) { double(:channel) }
|
51
|
+
|
52
|
+
let(:message) { DispatchRider::Message.new(subject: :test_handler, body: { "bar" => "baz" }) }
|
53
|
+
|
54
|
+
# @note: This is tested this way cause you don't really wanna post a message to the actual service.
|
42
55
|
it "publishes the message to the channels" do
|
43
|
-
|
44
|
-
|
45
|
-
|
56
|
+
expect(channel).to receive(:publish).with(kind_of String) { |serialized_message|
|
57
|
+
expect(JSON.parse(serialized_message)).to eq(
|
58
|
+
"subject" => "test_handler",
|
59
|
+
"body" => { "bar" => "baz" }
|
60
|
+
)
|
61
|
+
}
|
62
|
+
|
63
|
+
subject.publish_to_channel(channel, message: message)
|
46
64
|
end
|
47
65
|
end
|
48
66
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dispatch-rider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suman Mukherjee
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|