diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-06-21 11:16:39 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-06-21 11:16:39 +0000 |
commit | 4e8d6507bff12403d295b2d39432d50dcbeb7160 (patch) | |
tree | 48febd53a6b70681d80c2eb1457eaa7297873cb7 | |
parent | 6a3da45a22165f2f71c023e0656ff07820a1e60e (diff) | |
parent | 5eb940da76193524bd81d006fee9f7971c750ec0 (diff) | |
download | gitlab-ce-4e8d6507bff12403d295b2d39432d50dcbeb7160.tar.gz |
Merge branch 'zj-environment-creation-regex-fix' into 'master'
Replace invalid chars while seeding environments
Closes #30855
See merge request !12267
-rw-r--r-- | db/fixtures/development/19_environments.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/regex.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/regex_spec.rb | 12 |
3 files changed, 14 insertions, 2 deletions
diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb index 93214b9d3e7..c1bbc9af6d6 100644 --- a/db/fixtures/development/19_environments.rb +++ b/db/fixtures/development/19_environments.rb @@ -33,7 +33,7 @@ class Gitlab::Seeder::Environments create_deployment!( merge_request.source_project, - "review/#{merge_request.source_branch}", + "review/#{merge_request.source_branch.gsub(/[^a-zA-Z0-9]/, '')}", merge_request.source_branch, merge_request.diff_head_sha ) diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb index e4d2a992470..b706434217d 100644 --- a/lib/gitlab/regex.rb +++ b/lib/gitlab/regex.rb @@ -43,7 +43,7 @@ module Gitlab end def environment_name_regex_message - "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.' and spaces" + "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', and spaces" end def kubernetes_namespace_regex diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 0bee892fe0c..979f4fefcb6 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -21,6 +21,18 @@ describe Gitlab::Regex, lib: true do end describe '.environment_slug_regex' do + subject { described_class.environment_name_regex } + + it { is_expected.to match('foo') } + it { is_expected.to match('foo-1') } + it { is_expected.to match('FOO') } + it { is_expected.to match('foo/1') } + it { is_expected.to match('foo.1') } + it { is_expected.not_to match('9&foo') } + it { is_expected.not_to match('foo-^') } + end + + describe '.environment_slug_regex' do subject { described_class.environment_slug_regex } it { is_expected.to match('foo') } |