Commit 6574b745c311c663cdf860e36539eec7250434c5

Authored by mallowlabs
1 parent 1b1b5256
Exists in master and in 1 other branch production

add url to webhook service

app/models/notification_services/webhook_service.rb
@@ -13,7 +13,11 @@ class NotificationServices::WebhookService < NotificationService @@ -13,7 +13,11 @@ class NotificationServices::WebhookService < NotificationService
13 end 13 end
14 end 14 end
15 15
  16 + def message_for_webhook(problem)
  17 + {:problem => {:url => problem_url(problem)}.merge(problem.as_json).to_json}
  18 + end
  19 +
16 def create_notification(problem) 20 def create_notification(problem)
17 - HTTParty.post(api_token, :body => {:problem => problem.to_json}) 21 + HTTParty.post(api_token, :body => message_for_webhook(problem))
18 end 22 end
19 end 23 end
spec/models/notification_service/webhook_service_spec.rb
@@ -4,7 +4,8 @@ describe NotificationService::WebhookService, type: 'model' do @@ -4,7 +4,8 @@ describe NotificationService::WebhookService, type: 'model' do
4 notification_service = Fabricate :webhook_notification_service, :app => notice.app 4 notification_service = Fabricate :webhook_notification_service, :app => notice.app
5 problem = notice.problem 5 problem = notice.problem
6 6
7 - expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => {:problem => problem.to_json}).and_return(true) 7 + payload = notification_service.message_for_webhook(problem)
  8 + expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => payload).and_return(true)
8 9
9 notification_service.create_notification(problem) 10 notification_service.create_notification(problem)
10 end 11 end