babysitter 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -13,16 +13,21 @@ module Babysitter
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def notify(subject, msg)
|
16
|
-
|
17
|
-
subject[0..96] + "..."
|
18
|
-
else
|
19
|
-
subject
|
20
|
-
end
|
21
|
-
@topic.publish(msg, subject: sanitised_subject)
|
16
|
+
@topic.publish(msg, subject: sanitise_subject(subject))
|
22
17
|
end
|
23
18
|
|
24
19
|
private
|
25
20
|
|
21
|
+
def sanitise_subject(subject)
|
22
|
+
if subject.size > 100
|
23
|
+
subject[0..96] + "..."
|
24
|
+
elsif subject.empty?
|
25
|
+
"(no subject)"
|
26
|
+
else
|
27
|
+
subject
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
26
31
|
def validate_topic
|
27
32
|
@topic.display_name
|
28
33
|
end
|
data/lib/babysitter/version.rb
CHANGED
@@ -53,6 +53,12 @@ module Babysitter
|
|
53
53
|
|
54
54
|
subject.notify(original_subject, message)
|
55
55
|
end
|
56
|
+
|
57
|
+
it "handles empty subject" do
|
58
|
+
topic.should_receive(:publish).with(message, hash_including(subject: "(no subject)"))
|
59
|
+
|
60
|
+
subject.notify("", message)
|
61
|
+
end
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|