Skip to content
Snippets Groups Projects
Commit b5b6c7b1 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Sanitize container repository path in model class

parent 259108ad
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -20,7 +20,8 @@ class ContainerRepository < ActiveRecord::Base
end
 
def path
@path ||= [project.full_path, name].select(&:present?).join('/')
@path ||= [project.full_path, name]
.select(&:present?).join('/').downcase
end
 
def location
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ module ContainerRegistry
LEVELS_SUPPORTED = 3
 
def initialize(path)
@path = path.downcase
@path = path.to_s.downcase
end
 
def valid?
Loading
Loading
@@ -25,7 +25,7 @@ module ContainerRegistry
end
 
def components
@components ||= @path.to_s.split('/')
@components ||= @path.split('/')
end
 
def nodes
Loading
Loading
Loading
Loading
@@ -34,8 +34,18 @@ describe ContainerRepository do
end
 
describe '#path' do
it 'returns a full path to the repository' do
expect(repository.path).to eq('group/test/my_image')
context 'when project path does not contain uppercase letters' do
it 'returns a full path to the repository' do
expect(repository.path).to eq('group/test/my_image')
end
end
context 'when path contains uppercase letters' do
let(:project) { create(:project, path: 'MY_PROJECT', group: group) }
it 'returns a full path without capital letters' do
expect(repository.path).to eq('group/my_project/my_image')
end
end
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