viking-biobot 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/biobot.gemspec +1 -1
- data/lib/biobot/periodicals/notify.rb +6 -1
- data/test/biobot/periodicals/test_notify.rb +11 -6
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/biobot.gemspec
CHANGED
@@ -12,7 +12,12 @@ module Biobot
|
|
12
12
|
def handle_notifications
|
13
13
|
if Notification.count > 0
|
14
14
|
Notification.all.each do |notification|
|
15
|
-
|
15
|
+
to = notification.to
|
16
|
+
body = notification.body
|
17
|
+
message = Jabber::Message.new(
|
18
|
+
to =~ /@/ ? to : "#{to}@#{@server}",
|
19
|
+
body
|
20
|
+
)
|
16
21
|
@client.send(message)
|
17
22
|
end
|
18
23
|
Notification.delete_all
|
@@ -7,15 +7,20 @@ class TestNotify < Test::Unit::TestCase
|
|
7
7
|
@model = Biobot::Periodicals::Notify::Notification
|
8
8
|
@model.stubs(:inspect).returns('Notification')
|
9
9
|
@client = stub('Jabber::Client')
|
10
|
+
@server = 'localhost'
|
10
11
|
end
|
11
12
|
|
12
13
|
def test_handling_notifications
|
13
|
-
|
14
|
-
|
15
|
-
@model.expects(:
|
16
|
-
|
17
|
-
|
18
|
-
@
|
14
|
+
notification_1 = mock("notification", :to => 'foo@localhost', :body => 'huge')
|
15
|
+
notification_2 = mock("notification", :to => 'bar', :body => 'small')
|
16
|
+
@model.expects(:count).returns(2)
|
17
|
+
@model.expects(:all).returns([notification_1, notification_2])
|
18
|
+
outgoing_1 = mock_message('biobot@localhost', 'huge')
|
19
|
+
outgoing_2 = mock_message('biobot@localhost', 'small')
|
20
|
+
Jabber::Message.expects(:new).with('foo@localhost', 'huge').returns(outgoing_1)
|
21
|
+
Jabber::Message.expects(:new).with('bar@localhost', 'small').returns(outgoing_2)
|
22
|
+
@client.expects(:send).with(outgoing_1)
|
23
|
+
@client.expects(:send).with(outgoing_2)
|
19
24
|
@model.expects(:delete_all)
|
20
25
|
|
21
26
|
handle_notifications
|