Skip to content
Snippets Groups Projects
Commit 8fe05d83 authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Fix validation regexs (+1 squashed commit)

Squashed commits:
[f9a9315] Use : to test invalid environment name
parent 31e8721a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment