Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/models/webhook_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down