diff --git a/app/models/webhook.rb b/app/models/webhook.rb index 3b34af041..f008aa934 100644 --- a/app/models/webhook.rb +++ b/app/models/webhook.rb @@ -36,6 +36,7 @@ class Webhook < ApplicationRecord after_create :create_delinquency_tracker! normalizes :subscribed_actions, with: ->(value) { Array.wrap(value).map(&:to_s).uniq & PERMITTED_ACTIONS } + normalizes :url, with: -> { it.strip } validates :name, presence: true validate :validate_url diff --git a/test/models/webhook_test.rb b/test/models/webhook_test.rb index 52c43383d..121c1a651 100644 --- a/test/models/webhook_test.rb +++ b/test/models/webhook_test.rb @@ -35,6 +35,10 @@ class WebhookTest < ActiveSupport::TestCase webhook = Webhook.new name: "HTTPS", board: boards(:writebook), url: "https://example.com/webhook" assert webhook.valid? + + webhook = Webhook.new name: "TRAILING SPACE", board: boards(:writebook), url: "https://example.com/webhook " + assert webhook.valid? + assert_equal "https://example.com/webhook", webhook.url end test "deactivate" do