viking-biobot 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{biobot}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeremy Stephens"]
@@ -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
- message = Jabber::Message.new(notification.to, notification.body)
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
- notification = mock("notification", :to => 'foo@localhost', :body => 'huge')
14
- @model.expects(:count).returns(1)
15
- @model.expects(:all).returns([notification])
16
- outgoing = mock_message('biobot@localhost', 'huge')
17
- Jabber::Message.expects(:new).with('foo@localhost', 'huge').returns(outgoing)
18
- @client.expects(:send).with(outgoing)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viking-biobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Stephens