Merge pull request #5605 from tchak/fix-web-hook-jobs
Do not enqueue web hooks for empty urls
This commit is contained in:
commit
e0e635d65b
2 changed files with 17 additions and 1 deletions
|
@ -822,7 +822,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
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(
|
||||
procedure,
|
||||
self
|
||||
|
|
|
@ -813,6 +813,22 @@ describe Dossier do
|
|||
}.to_not have_enqueued_job(WebHookJob)
|
||||
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
|
||||
dossier.procedure.update_column(:web_hook_url, '/webhook.json')
|
||||
|
||||
|
|
Loading…
Reference in a new issue