summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-09-19 09:01:04 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-09-19 10:07:15 +0200
commit8fe05d83ac259bf8a0fa4ca344d330a1c0cea8bb (patch)
tree6ff8ed2edcfdf163adcd729af1f036d4c4cf4922
parent31e8721a44ceddc4d3578f3af2b6c7a1797be35b (diff)
downloadgitlab-ce-8fe05d83ac259bf8a0fa4ca344d330a1c0cea8bb.tar.gz
Fix validation regexs (+1 squashed commit)
Squashed commits: [f9a9315] Use : to test invalid environment name
-rw-r--r--lib/gitlab/regex.rb4
-rw-r--r--spec/features/environments_spec.rb2
-rw-r--r--spec/lib/ci/gitlab_ci_yaml_processor_spec.rb4
-rw-r--r--spec/models/environment_spec.rb4
4 files changed, 7 insertions, 7 deletions
diff --git a/lib/gitlab/regex.rb b/lib/gitlab/regex.rb
index 4efd9ae2c1e..bc8bbf337f3 100644
--- a/lib/gitlab/regex.rb
+++ b/lib/gitlab/regex.rb
@@ -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
diff --git a/spec/features/environments_spec.rb b/spec/features/environments_spec.rb
index fcd41b38413..4309a726917 100644
--- a/spec/features/environments_spec.rb
+++ b/spec/features/environments_spec.rb
@@ -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
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
index c139ef36a9a..6dedd25e9d3 100644
--- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
@@ -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
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 7afc7ec5ca1..6b1867a44e1 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -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