adjust webhooks
This commit is contained in:
@@ -56,14 +56,6 @@ RSpec.describe SendFormCompletedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the submitter doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('submitter_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['form.declined'])
|
||||
|
||||
@@ -72,12 +64,6 @@ RSpec.describe SendFormCompletedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('submitter_id' => submitter.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -56,14 +56,6 @@ RSpec.describe SendFormDeclinedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the submitter doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('submitter_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['form.completed'])
|
||||
|
||||
@@ -72,12 +64,6 @@ RSpec.describe SendFormDeclinedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('submitter_id' => submitter.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -56,14 +56,6 @@ RSpec.describe SendFormStartedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the submitter doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('submitter_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['form.declined'])
|
||||
|
||||
@@ -72,12 +64,6 @@ RSpec.describe SendFormStartedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('submitter_id' => submitter.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -56,14 +56,6 @@ RSpec.describe SendFormViewedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the submitter doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('submitter_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['form.started'])
|
||||
|
||||
@@ -72,12 +64,6 @@ RSpec.describe SendFormViewedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('submitter_id' => submitter.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -53,14 +53,6 @@ RSpec.describe SendSubmissionArchivedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the submission doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('submission_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['submission.created'])
|
||||
|
||||
@@ -69,12 +61,6 @@ RSpec.describe SendSubmissionArchivedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('submission_id' => submission.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -53,14 +53,6 @@ RSpec.describe SendSubmissionCompletedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the submission doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('submission_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['submission.archived'])
|
||||
|
||||
@@ -69,12 +61,6 @@ RSpec.describe SendSubmissionCompletedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('submission_id' => submission.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -53,14 +53,6 @@ RSpec.describe SendSubmissionCreatedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the submission doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('submission_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['submission.completed'])
|
||||
|
||||
@@ -69,12 +61,6 @@ RSpec.describe SendSubmissionCreatedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('submission_id' => submission.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -52,14 +52,6 @@ RSpec.describe SendTemplateCreatedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the template doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('template_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['template.updated'])
|
||||
|
||||
@@ -68,12 +60,6 @@ RSpec.describe SendTemplateCreatedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('template_id' => template.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -52,14 +52,6 @@ RSpec.describe SendTemplateUpdatedWebhookRequestJob do
|
||||
).once
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the template doesn't exist" do
|
||||
expect do
|
||||
described_class.new.perform('template_id' => 100_500, 'webhook_url_id' => webhook_url.id)
|
||||
end.to raise_error ActiveRecord::RecordNotFound
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the event is not in the webhook's events" do
|
||||
webhook_url.update!(events: ['template.created'])
|
||||
|
||||
@@ -68,12 +60,6 @@ RSpec.describe SendTemplateUpdatedWebhookRequestJob do
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it "doesn't send a webhook request if the webhook doesn't exist" do
|
||||
described_class.new.perform('template_id' => template.id, 'webhook_url_id' => 100_500)
|
||||
|
||||
expect(WebMock).not_to have_requested(:post, webhook_url.url)
|
||||
end
|
||||
|
||||
it 'sends again if the response status is 400 or higher' do
|
||||
stub_request(:post, webhook_url.url).to_return(status: 401)
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ RSpec.describe 'Webhook Settings' do
|
||||
|
||||
visit settings_webhooks_path
|
||||
|
||||
expect(webhook_url.secret).to be_nil
|
||||
expect(webhook_url.secret).to eq({})
|
||||
|
||||
click_link 'Add Secret'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user