From 859b7703d108678204d5e4eba41f5a537bd43fd6 Mon Sep 17 00:00:00 2001 From: Shimpei Makimoto Date: Mon, 22 May 2017 10:04:38 +0900 Subject: [PATCH] Fix length validation for slack_channel column to adapt # symbol Slack's channel length is up to 21 characters without `#` symbol at the head. However JobDefinition#slack_channel's maximum length is 21 with `#`. So I change the length to 22 characters to allow 21-character channel names. --- app/models/kuroko2/job_definition.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/models/kuroko2/job_definition.rb b/app/models/kuroko2/job_definition.rb index 77e93a97..98fb974f 100644 --- a/app/models/kuroko2/job_definition.rb +++ b/app/models/kuroko2/job_definition.rb @@ -67,10 +67,12 @@ module PreventMultiStatus validate :script_syntax validate :validate_number_of_admins validates :hipchat_additional_text, length: { maximum: 180 } - validates :slack_channel, length: { maximum: 21 }, format: { - with: /\A#[^\.\s]+\z/, allow_blank: true, - message: ' must start with # and must not include any dots or spaces' - } + validates :slack_channel, + length: { maximum: 22, too_long: ' is too long (maximum is 21 characters without `#` symbol at the head)' }, + format: { + with: /\A#[^\.\s]+\z/, allow_blank: true, + message: ' must start with # and must not include any dots or spaces' + } validates :webhook_url, format: { with: /\A#{URI::regexp(%w(http https))}\z/, allow_blank: true } def proceed_multi_instance?