Add support for Basecamp, Campfire & Slack webhooks
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user