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 ...@@ -96,11 +96,11 @@ module Gitlab
end end
def environment_name_regex 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 end
def environment_name_regex_message def environment_name_regex_message
"can contain only letters, digits, '-', '_', '/', '$', '{', '}' and spaces" "can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.' and spaces"
end end
end end
end end
...@@ -150,7 +150,7 @@ feature 'Environments', feature: true do ...@@ -150,7 +150,7 @@ feature 'Environments', feature: true do
context 'for invalid name' do context 'for invalid name' do
before do before do
fill_in('Name', with: 'name with spaces') fill_in('Name', with: 'name,with,commas')
click_on 'Save' click_on 'Save'
end end
......
...@@ -790,10 +790,10 @@ module Ci ...@@ -790,10 +790,10 @@ module Ci
end end
context 'is not a valid string' do context 'is not a valid string' do
let(:environment) { 'production staging' } let(:environment) { 'production:staging' }
it 'raises error' do 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 end
end end
......
...@@ -68,13 +68,13 @@ describe Environment, models: true do ...@@ -68,13 +68,13 @@ describe Environment, models: true do
subject { environment.environment_type } subject { environment.environment_type }
it 'sets a environment type if name has multiple segments' do 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') is_expected.to eq('production')
end end
it 'nullifies a type if it\'s a simple name' do it 'nullifies a type if it\'s a simple name' do
environment.update(name: 'production') environment.update!(name: 'production')
is_expected.to be_nil is_expected.to be_nil
end 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