Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
b5b6c7b1
Commit
b5b6c7b1
authored
Apr 13, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sanitize container repository path in model class
parent
259108ad
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
app/models/container_repository.rb
app/models/container_repository.rb
+2
-1
lib/container_registry/path.rb
lib/container_registry/path.rb
+2
-2
spec/models/container_repository_spec.rb
spec/models/container_repository_spec.rb
+12
-2
No files found.
app/models/container_repository.rb
View file @
b5b6c7b1
...
...
@@ -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
...
...
lib/container_registry/path.rb
View file @
b5b6c7b1
...
...
@@ -15,7 +15,7 @@ module ContainerRegistry
LEVELS_SUPPORTED
=
3
def
initialize
(
path
)
@path
=
path
.
downcase
@path
=
path
.
to_s
.
downcase
end
def
valid?
...
...
@@ -25,7 +25,7 @@ module ContainerRegistry
end
def
components
@components
||=
@path
.
to_s
.
split
(
'/'
)
@components
||=
@path
.
split
(
'/'
)
end
def
nodes
...
...
spec/models/container_repository_spec.rb
View file @
b5b6c7b1
...
...
@@ -34,11 +34,21 @@ describe ContainerRepository do
end
describe
'#path'
do
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
describe
'#manifest'
do
it
'returns non-empty manifest'
do
expect
(
repository
.
manifest
).
not_to
be_nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment