Commit 3c9449ab436dd7cfa1c165ad3d8e8fe5a934ed3d

Authored by Arthur Nogueira Neves
2 parents 1b1b5256 6574b745
Exists in master and in 1 other branch production

Merge pull request #860 from mallowlabs/add_url_to_webhook

Add url to webhook service
app/models/notification_services/webhook_service.rb
... ... @@ -13,7 +13,11 @@ class NotificationServices::WebhookService < NotificationService
13 13 end
14 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 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 22 end
19 23 end
... ...
spec/models/notification_service/webhook_service_spec.rb
... ... @@ -4,7 +4,8 @@ describe NotificationService::WebhookService, type: 'model' do
4 4 notification_service = Fabricate :webhook_notification_service, :app => notice.app
5 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 10 notification_service.create_notification(problem)
10 11 end
... ...