diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/lib/gitlab/kubernetes/default_namespace_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) | |
download | gitlab-ce-8c890596f5d0792c467fe12805ab1b39f93bf140.tar.gz |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/lib/gitlab/kubernetes/default_namespace_spec.rb')
-rw-r--r-- | spec/lib/gitlab/kubernetes/default_namespace_spec.rb | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/spec/lib/gitlab/kubernetes/default_namespace_spec.rb b/spec/lib/gitlab/kubernetes/default_namespace_spec.rb index 976fe4a0a87..b6816a18baa 100644 --- a/spec/lib/gitlab/kubernetes/default_namespace_spec.rb +++ b/spec/lib/gitlab/kubernetes/default_namespace_spec.rb @@ -32,6 +32,14 @@ RSpec.describe Gitlab::Kubernetes::DefaultNamespace do subject { generator.from_environment_slug(environment.slug) } + shared_examples_for 'handles very long project paths' do + before do + allow(project).to receive(:path).and_return 'x' * 100 + end + + it { is_expected.to satisfy { |s| s.length <= 63 } } + end + context 'namespace per environment is enabled' do context 'platform namespace is specified' do let(:platform_namespace) { 'platform-namespace' } @@ -47,15 +55,12 @@ RSpec.describe Gitlab::Kubernetes::DefaultNamespace do context 'platform namespace is blank' do let(:platform_namespace) { nil } - let(:mock_namespace) { 'mock-namespace' } - it 'constructs a namespace from the project and environment' do - expect(Gitlab::NamespaceSanitizer).to receive(:sanitize) - .with("#{project.path}-#{project.id}-#{environment.slug}".downcase) - .and_return(mock_namespace) - - expect(subject).to eq mock_namespace + it 'constructs a namespace from the project and environment slug' do + expect(subject).to eq "path-with-capitals-#{project.id}-#{environment.slug}" end + + it_behaves_like 'handles very long project paths' end end @@ -70,15 +75,12 @@ RSpec.describe Gitlab::Kubernetes::DefaultNamespace do context 'platform namespace is blank' do let(:platform_namespace) { nil } - let(:mock_namespace) { 'mock-namespace' } - it 'constructs a namespace from the project and environment' do - expect(Gitlab::NamespaceSanitizer).to receive(:sanitize) - .with("#{project.path}-#{project.id}".downcase) - .and_return(mock_namespace) - - expect(subject).to eq mock_namespace + it 'constructs a namespace from just the project' do + expect(subject).to eq "path-with-capitals-#{project.id}" end + + it_behaves_like 'handles very long project paths' end end end |