Skip to content

Commit

Permalink
Merge pull request #860 from mallowlabs/add_url_to_webhook
Browse files Browse the repository at this point in the history
Add url to webhook service
  • Loading branch information
Arthur Nogueira Neves committed Mar 21, 2015
2 parents 1b1b525 + 6574b74 commit 3c9449a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/models/notification_services/webhook_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ def check_params
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
3 changes: 2 additions & 1 deletion spec/models/notification_service/webhook_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
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
Expand Down

0 comments on commit 3c9449a

Please sign in to comment.