Commit c0da3be57a43e43864d3dab6824487ae699a7dd7
1 parent
93fadbe0
Exists in
master
and in
1 other branch
added tests
Showing
1 changed file
with
48 additions
and
0 deletions
Show diff stats
spec/models/notification_service/gtalk_service_spec.rb
| @@ -23,5 +23,53 @@ describe NotificationService::GtalkService do | @@ -23,5 +23,53 @@ describe NotificationService::GtalkService do | ||
| 23 | 23 | ||
| 24 | notification_service.create_notification(problem) | 24 | notification_service.create_notification(problem) |
| 25 | end | 25 | end |
| 26 | + | ||
| 27 | + describe "multiple room_ids (or users)" do | ||
| 28 | + before(:each) do | ||
| 29 | + # setup | ||
| 30 | + @notice = Fabricate :notice | ||
| 31 | + @notification_service = Fabricate :gtalk_notification_service, :app => @notice.app | ||
| 32 | + @problem = @notice.problem | ||
| 33 | + @error_msg = "[errbit] http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} #{@notification_service.notification_description @problem}" | ||
| 34 | + | ||
| 35 | + # gtalk stubbing | ||
| 36 | + @gtalk = mock('GtalkService') | ||
| 37 | + @gtalk.should_receive(:connect) | ||
| 38 | + @gtalk.should_receive(:auth) | ||
| 39 | + jid = double("jid") | ||
| 40 | + Jabber::JID.stub(:new).with(@notification_service.subdomain).and_return(jid) | ||
| 41 | + Jabber::Client.stub(:new).with(jid).and_return(@gtalk) | ||
| 42 | + end | ||
| 43 | + it "should send a notification to all ',' separated users" do | ||
| 44 | + Jabber::Message.should_receive(:new).with("first@domain.org", @error_msg) | ||
| 45 | + Jabber::Message.should_receive(:new).with("second@domain.org", @error_msg) | ||
| 46 | + Jabber::Message.should_receive(:new).with("third@domain.org", @error_msg) | ||
| 47 | + Jabber::Message.should_receive(:new).with("fourth@domain.org", @error_msg) | ||
| 48 | + @gtalk.should_receive(:send).exactly(4).times | ||
| 49 | + | ||
| 50 | + @notification_service.room_id = "first@domain.org,second@domain.org, third@domain.org , fourth@domain.org " | ||
| 51 | + @notification_service.create_notification(@problem) | ||
| 52 | + end | ||
| 53 | + it "should send a notification to all ';' separated users" do | ||
| 54 | + Jabber::Message.should_receive(:new).with("first@domain.org", @error_msg) | ||
| 55 | + Jabber::Message.should_receive(:new).with("second@domain.org", @error_msg) | ||
| 56 | + Jabber::Message.should_receive(:new).with("third@domain.org", @error_msg) | ||
| 57 | + Jabber::Message.should_receive(:new).with("fourth@domain.org", @error_msg) | ||
| 58 | + @gtalk.should_receive(:send).exactly(4).times | ||
| 59 | + | ||
| 60 | + @notification_service.room_id = "first@domain.org;second@domain.org; third@domain.org ; fourth@domain.org " | ||
| 61 | + @notification_service.create_notification(@problem) | ||
| 62 | + end | ||
| 63 | + it "should send a notification to all ' ' separated users" do | ||
| 64 | + Jabber::Message.should_receive(:new).with("first@domain.org", @error_msg) | ||
| 65 | + Jabber::Message.should_receive(:new).with("second@domain.org", @error_msg) | ||
| 66 | + Jabber::Message.should_receive(:new).with("third@domain.org", @error_msg) | ||
| 67 | + Jabber::Message.should_receive(:new).with("fourth@domain.org", @error_msg) | ||
| 68 | + @gtalk.should_receive(:send).exactly(4).times | ||
| 69 | + | ||
| 70 | + @notification_service.room_id = "first@domain.org second@domain.org third@domain.org fourth@domain.org " | ||
| 71 | + @notification_service.create_notification(@problem) | ||
| 72 | + end | ||
| 73 | + end | ||
| 26 | end | 74 | end |
| 27 | 75 |