1
0

webhook_service_spec.rb 830 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe WebhookService do
  4. describe '#call' do
  5. context 'with a relevant event webhook' do
  6. let!(:report) { Fabricate(:report) }
  7. let!(:webhook) { Fabricate(:webhook, events: ['report.created']) }
  8. it 'finds and delivers webhook payloads' do
  9. expect { subject.call('report.created', report) }
  10. .to enqueue_sidekiq_job(Webhooks::DeliveryWorker)
  11. .with(
  12. webhook.id,
  13. anything
  14. )
  15. end
  16. end
  17. context 'without any relevant event webhooks' do
  18. let!(:report) { Fabricate(:report) }
  19. it 'does not deliver webhook payloads' do
  20. expect { subject.call('report.created', report) }
  21. .to_not enqueue_sidekiq_job(Webhooks::DeliveryWorker)
  22. end
  23. end
  24. end
  25. end