diff --git a/app/models/notification_services/gtalk_service.rb b/app/models/notification_services/gtalk_service.rb index 79d589b..1e39dfc 100644 --- a/app/models/notification_services/gtalk_service.rb +++ b/app/models/notification_services/gtalk_service.rb @@ -53,6 +53,8 @@ class NotificationServices::GtalkService < NotificationService # post the issue to the xmpp room(s) send_to_users(client, message) unless user_id.blank? send_to_muc(client, message) unless room_id.blank? + ensure + client.close unless client.nil? end private diff --git a/spec/models/notification_service/gtalk_service_spec.rb b/spec/models/notification_service/gtalk_service_spec.rb index 08d0d9a..da71819 100644 --- a/spec/models/notification_service/gtalk_service_spec.rb +++ b/spec/models/notification_service/gtalk_service_spec.rb @@ -28,6 +28,7 @@ describe NotificationService::GtalkService do #assert expect(gtalk).to receive(:send).exactly(2).times.with(message) + expect(gtalk).to receive(:close) notification_service.create_notification(problem) end @@ -57,6 +58,7 @@ describe NotificationService::GtalkService do expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg) expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new) expect(@gtalk).to receive(:send).exactly(4).times + expect(@gtalk).to receive(:close) @notification_service.user_id = "first@domain.org,second@domain.org, third@domain.org , fourth@domain.org " @notification_service.room_id = "" @@ -69,6 +71,7 @@ describe NotificationService::GtalkService do expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg) expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new) expect(@gtalk).to receive(:send).exactly(4).times + expect(@gtalk).to receive(:close) @notification_service.user_id = "first@domain.org;second@domain.org; third@domain.org ; fourth@domain.org " @notification_service.room_id = "" @@ -81,6 +84,7 @@ describe NotificationService::GtalkService do expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg) expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new) expect(@gtalk).to receive(:send).exactly(4).times + expect(@gtalk).to receive(:close) @notification_service.user_id = "first@domain.org second@domain.org third@domain.org fourth@domain.org " @notification_service.room_id = "" @@ -117,6 +121,7 @@ describe NotificationService::GtalkService do #assert expect(gtalk).to receive(:send).with(message) + expect(gtalk).to receive(:close) notification_service.create_notification(problem) end -- libgit2 0.21.2