Commit 8fe05d83 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix validation regexs (+1 squashed commit)

Squashed commits:
[f9a9315] Use : to test invalid environment name
parent 31e8721a
......@@ -96,11 +96,11 @@ module Gitlab
end
def environment_name_regex
@environment_name_regex ||= /\A[a-zA-Z0-9_\\\/\${} -]+\z/.freeze
@environment_name_regex ||= /\A[a-zA-Z0-9_\\\/\${}. -]+\z/.freeze
end
def environment_name_regex_message
"can contain only letters, digits, '-', '_', '/', '$', '{', '}' and spaces"
"can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.' and spaces"
end
end
end
......@@ -150,7 +150,7 @@ feature 'Environments', feature: true do
context 'for invalid name' do
before do
fill_in('Name', with: 'name with spaces')
fill_in('Name', with: 'name,with,commas')
click_on 'Save'
end
......
......@@ -790,10 +790,10 @@ module Ci
end
context 'is not a valid string' do
let(:environment) { 'production staging' }
let(:environment) { 'production:staging' }
it 'raises error' do
expect { builds }.to raise_error("jobs:deploy_to_production environment #{Gitlab::Regex.environment_name_regex_message}")
expect { builds }.to raise_error("jobs:deploy_to_production:environment name #{Gitlab::Regex.environment_name_regex_message}")
end
end
end
......
......@@ -68,13 +68,13 @@ describe Environment, models: true do
subject { environment.environment_type }
it 'sets a environment type if name has multiple segments' do
environment.update(name: 'production/worker.gitlab.com')
environment.update!(name: 'production/worker.gitlab.com')
is_expected.to eq('production')
end
it 'nullifies a type if it\'s a simple name' do
environment.update(name: 'production')
environment.update!(name: 'production')
is_expected.to be_nil
end
......
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