issue_3372_webhooks_admin_view_spec.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. require 'rails_helper'
  2. RSpec.describe Issue3372WebhooksAdminView, type: :db_migration do
  3. let(:trigger_webhook_config) do
  4. {
  5. 'endpoint' => 'https://example.com/webhook',
  6. 'token' => '53Cr3T',
  7. 'verify_ssl' => false,
  8. }
  9. end
  10. let(:webhook_attributes) do
  11. {
  12. endpoint: trigger_webhook_config['endpoint'],
  13. signature_token: trigger_webhook_config['token'],
  14. ssl_verify: trigger_webhook_config['verify_ssl'],
  15. }
  16. end
  17. let!(:trigger) do
  18. Trigger.without_callback(:create, :before, :validate_perform) do
  19. create(:trigger, perform: {
  20. 'notification.webhook' => trigger_webhook_config
  21. })
  22. end
  23. end
  24. it 'Creates Webhook object from mapped Trigger configuration' do
  25. migrate do |migration|
  26. allow(migration).to receive(:create_webhooks_table)
  27. end
  28. expect(Webhook.last).to have_attributes(**webhook_attributes)
  29. end
  30. it 'Migrates Trigger#perform Webhook configuration to new structure' do
  31. migrate do |migration|
  32. allow(migration).to receive(:create_webhooks_table)
  33. end
  34. expect(trigger.reload.perform['notification.webhook']['webhook_id']).to eq(Webhook.last.id)
  35. end
  36. end