Add support for Basecamp, Campfire & Slack webhooks

This commit is contained in:
Stanko K.R.
2025-09-12 15:32:00 +02:00
parent 4879995013
commit 2fc9215b1d
5 changed files with 186 additions and 2 deletions
+51
View File
@@ -52,4 +52,55 @@ class WebhookTest < ActiveSupport::TestCase
webhook.activate
end
end
test "for_slack?" do
webhook = Webhook.new name: "Test", url: "https://hooks.slack.com/services/T12345678/B12345678/abcdefghijklmnopqrstuvwx"
assert webhook.for_slack?
webhook = Webhook.new name: "Test", url: "https://hooks.slack.com/services/T12345678/B12345678"
assert_not webhook.for_slack?
webhook = Webhook.new name: "Test", url: "https://hooks.slack.com/services/T12345678"
assert_not webhook.for_slack?
webhook = Webhook.new name: "Test", url: "https://hooks.slack.com/services/"
assert_not webhook.for_slack?
webhook = Webhook.new name: "Test", url: "https://example.com/webhook"
assert_not webhook.for_slack?
end
test "for_campfire?" do
webhook = Webhook.new name: "Test", url: "https://example.com/rooms/123/456-room-name/messages"
assert webhook.for_campfire?
webhook = Webhook.new name: "Test", url: "https://campfire.example.com/rooms/999/123-test-room/messages"
assert webhook.for_campfire?
webhook = Webhook.new name: "Test", url: "https://campfire.example.com/rooms/999/123/messages"
assert_not webhook.for_campfire?, "The bot key is missing a token"
webhook = Webhook.new name: "Test", url: "https://example.com/webhook"
assert_not webhook.for_campfire?
webhook = Webhook.new name: "Test", url: "https://example.com/rooms/123/messages"
assert_not webhook.for_campfire?
webhook = Webhook.new name: "Test", url: "https://example.com/rooms/123/456-room-name/"
assert_not webhook.for_campfire?
end
test "for_basecamp?" do
webhook = Webhook.new name: "Test", url: "https://basecamp.com/999/integrations/some-token/buckets/111/chats/222/lines"
assert webhook.for_basecamp?
webhook = Webhook.new name: "Test", url: "https://example.com/webhook"
assert_not webhook.for_basecamp?
webhook = Webhook.new name: "Test", url: "https://3.basecamp.com/123/integrations/webhook/buckets/456/chats/"
assert_not webhook.for_basecamp?
webhook = Webhook.new name: "Test", url: "https://3.basecamp.com/integrations/webhook/buckets/456/chats/789/lines"
assert_not webhook.for_basecamp?
end
end