Commit e342328a authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix-prject-key' into 'master'

Fix validation of project_key

See merge request gitlab-org/gitlab!24682
parents 6ea8d9a3 5080c8fe
......@@ -8,7 +8,7 @@ class ServiceDeskSetting < ApplicationRecord
validate :valid_issue_template
validates :outgoing_name, length: { maximum: 255 }, allow_blank: true
validates :project_key, length: { maximum: 255 }, allow_blank: true, format: { with: /\A[a-z0-9_]+\z/ }
validates_uniqueness_of :project_key
validates_uniqueness_of :project_key, allow_nil: true
def issue_template_content
strong_memoize(:issue_template_content) do
......
......@@ -9,7 +9,7 @@ describe ServiceDeskSetting do
it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_length_of(:outgoing_name).is_at_most(255) }
it { is_expected.to validate_length_of(:project_key).is_at_most(255) }
it { is_expected.to validate_uniqueness_of(:project_key) }
it { is_expected.to validate_uniqueness_of(:project_key).allow_nil }
it { is_expected.to allow_value('abc123_').for(:project_key) }
it { is_expected.not_to allow_value('abc 12').for(:project_key) }
it { is_expected.not_to allow_value('Big val').for(:project_key) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment