mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FEATURE: Merge discourse-automation (#26432)
Automation (previously known as discourse-automation) is now a core plugin.
This commit is contained in:
42
plugins/automation/spec/scripts/zapier_webhook_spec.rb
Normal file
42
plugins/automation/spec/scripts/zapier_webhook_spec.rb
Normal file
@ -0,0 +1,42 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "../discourse_automation_helper"
|
||||
|
||||
describe "ZapierWebhook" do
|
||||
fab!(:topic)
|
||||
|
||||
fab!(:automation) { Fabricate(:automation, script: DiscourseAutomation::Scripts::ZAPIER_WEBHOOK) }
|
||||
|
||||
context "with valid webhook url" do
|
||||
before do
|
||||
automation.upsert_field!(
|
||||
"webhook_url",
|
||||
"text",
|
||||
{ value: "https://hooks.zapier.com/hooks/catch/foo/bar" },
|
||||
)
|
||||
end
|
||||
|
||||
it "enqueues the zapier call" do
|
||||
expect { automation.trigger! }.to change {
|
||||
Jobs::DiscourseAutomationCallZapierWebhook.jobs.length
|
||||
}.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid webhook url" do
|
||||
before do
|
||||
@orig_logger = Rails.logger
|
||||
Rails.logger = @fake_logger = FakeLogger.new
|
||||
end
|
||||
|
||||
after { Rails.logger = @orig_logger }
|
||||
|
||||
it "logs an error and do nothing" do
|
||||
expect { automation.trigger! }.not_to change {
|
||||
Jobs::DiscourseAutomationCallZapierWebhook.jobs.length
|
||||
}
|
||||
|
||||
expect(Rails.logger.warnings.first).to match(/is not a valid Zapier/)
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user