Merge pull request #5605 from tchak/fix-web-hook-jobs

Do not enqueue web hooks for empty urls
This commit is contained in:
Paul Chavard 2020-09-22 17:20:57 +02:00 committed by GitHub
commit e0e635d65b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -822,7 +822,7 @@ class Dossier < ApplicationRecord
end end
def send_web_hook def send_web_hook
if saved_change_to_state? && !brouillon? && procedure.web_hook_url if saved_change_to_state? && !brouillon? && procedure.web_hook_url.present?
WebHookJob.perform_later( WebHookJob.perform_later(
procedure, procedure,
self self

View file

@ -813,6 +813,22 @@ describe Dossier do
}.to_not have_enqueued_job(WebHookJob) }.to_not have_enqueued_job(WebHookJob)
end end
it 'should not call webhook with empty value' do
dossier.procedure.update_column(:web_hook_url, '')
expect {
dossier.accepte!
}.to_not have_enqueued_job(WebHookJob)
end
it 'should not call webhook with blank value' do
dossier.procedure.update_column(:web_hook_url, ' ')
expect {
dossier.accepte!
}.to_not have_enqueued_job(WebHookJob)
end
it 'should call webhook' do it 'should call webhook' do
dossier.procedure.update_column(:web_hook_url, '/webhook.json') dossier.procedure.update_column(:web_hook_url, '/webhook.json')