-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9573 from demarches-simplifiees/add-sentry-to-web…
…hook-call remonte les erreurs dans Sentry lorsqu'un appel webhook est en erreur
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
describe WebHookJob, type: :job do | ||
describe 'perform' do | ||
let(:procedure) { create(:procedure, web_hook_url:) } | ||
let(:dossier) { create(:dossier, procedure:) } | ||
let(:web_hook_url) { "https://domaine.fr/callback_url" } | ||
let(:job) { WebHookJob.new(procedure.id, dossier.id, dossier.state, dossier.updated_at) } | ||
|
||
context 'with success on webhook' do | ||
it 'calls webhook' do | ||
stub_request(:post, web_hook_url).to_return(status: 200, body: "success") | ||
expect { job.perform_now }.not_to raise_error | ||
end | ||
end | ||
|
||
context 'with error on webhook' do | ||
it 'raises' do | ||
stub_request(:post, web_hook_url).to_return(status: 500, body: "error") | ||
expect { job.perform_now }.to raise_error | ||
end | ||
end | ||
end | ||
end |