From 6574b745c311c663cdf860e36539eec7250434c5 Mon Sep 17 00:00:00 2001 From: mallowlabs Date: Sat, 21 Mar 2015 00:49:46 +0900 Subject: [PATCH] add url to webhook service --- app/models/notification_services/webhook_service.rb | 6 +++++- spec/models/notification_service/webhook_service_spec.rb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/notification_services/webhook_service.rb b/app/models/notification_services/webhook_service.rb index 4f3fa5a..6d5b999 100644 --- a/app/models/notification_services/webhook_service.rb +++ b/app/models/notification_services/webhook_service.rb @@ -13,7 +13,11 @@ class NotificationServices::WebhookService < NotificationService end end + def message_for_webhook(problem) + {:problem => {:url => problem_url(problem)}.merge(problem.as_json).to_json} + end + def create_notification(problem) - HTTParty.post(api_token, :body => {:problem => problem.to_json}) + HTTParty.post(api_token, :body => message_for_webhook(problem)) end end diff --git a/spec/models/notification_service/webhook_service_spec.rb b/spec/models/notification_service/webhook_service_spec.rb index ce73b8a..0550b30 100644 --- a/spec/models/notification_service/webhook_service_spec.rb +++ b/spec/models/notification_service/webhook_service_spec.rb @@ -4,7 +4,8 @@ describe NotificationService::WebhookService, type: 'model' do notification_service = Fabricate :webhook_notification_service, :app => notice.app problem = notice.problem - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => {:problem => problem.to_json}).and_return(true) + payload = notification_service.message_for_webhook(problem) + expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => payload).and_return(true) notification_service.create_notification(problem) end -- libgit2 0.21.2