Skip to content
代码片段 群组 项目
提交 1bfe6b2c 编辑于 作者: Luke Duncalfe's avatar Luke Duncalfe
浏览文件

Improve error message for webhook name description

The length constraints were added to the `web_hooks` table when the
columns were migrated
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/141977.

This change adds corresponding model validations to improve the error
messages returned.

Changelog: changed
上级 0fa2e7bb
No related branches found
No related tags found
无相关合并请求
......@@ -65,6 +65,8 @@ module Hook
validates :interpolated_url, public_url: true, if: ->(hook) { hook.url_variables? && hook.errors.empty? }
validates :custom_headers, json_schema: { filename: 'web_hooks_custom_headers' }
validates :custom_webhook_template, length: { maximum: 4096 }
validates :name, length: { maximum: 255 }
validates :description, length: { maximum: 2048 }
enum :branch_filter_strategy, {
wildcard: 0,
......
......@@ -18,6 +18,8 @@
describe 'validations' do
it { is_expected.to validate_presence_of(:url) }
it { is_expected.to validate_length_of(:custom_webhook_template).is_at_most(4096) }
it { is_expected.to validate_length_of(:name).is_at_most(255) }
it { is_expected.to validate_length_of(:description).is_at_most(2048) }
describe 'url_variables' do
it { is_expected.to allow_value({}).for(:url_variables) }
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册