Skip to content

Commit

Permalink
Fix webhook service notification payload (errbit#1216)
Browse files Browse the repository at this point in the history
NotificationServices::WebhookService#message_for_webhook
previously returned an Hash with a single key "problem"
with a string as value:

{
    "problem": "Stringified json here"
}

actually loosing almost all the "problem" properties.

Now the "problem" key bring on a child Hash as expected.
  • Loading branch information
alessandro-fazzi authored and stevecrozz committed Sep 5, 2017
1 parent 8424177 commit 6c2fde9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/notification_services/webhook_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def check_params

def message_for_webhook(problem)
{
problem: { url: problem.url }.merge(problem.as_json).to_json
problem: { url: problem.url }.merge(problem.as_json)
}
end

Expand Down
12 changes: 12 additions & 0 deletions spec/models/notification_service/webhook_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,16 @@

notification_service.create_notification(problem)
end

context "#message_for_webhook" do
it "should return an hash with all the keys nested inside 'problem' key" do
notice = Fabricate :notice
notification_service = Fabricate :webhook_notification_service, app: notice.app
problem = notice.problem

payload = notification_service.message_for_webhook(problem)

expect(payload[:problem]).to be_a(Hash)
end
end
end

0 comments on commit 6c2fde9

Please sign in to comment.