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
Jérome Perrin
gitlab-ce
Commits
bdc1e1b9
Commit
bdc1e1b9
authored
Mar 28, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement method matching container repository names
parent
b15d9042
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
1 deletion
+52
-1
lib/container_registry/path.rb
lib/container_registry/path.rb
+8
-0
spec/lib/container_registry/path_spec.rb
spec/lib/container_registry/path_spec.rb
+44
-1
No files found.
lib/container_registry/path.rb
View file @
bdc1e1b9
...
...
@@ -3,6 +3,7 @@ module ContainerRegistry
InvalidRegistryPathError
=
Class
.
new
(
StandardError
)
def
initialize
(
name
)
@name
=
name
@nodes
=
name
.
to_s
.
split
(
'/'
)
end
...
...
@@ -19,11 +20,18 @@ module ContainerRegistry
end
end
def
has_repository?
# ContainerRepository.find_by_full_path(@name).present?
end
def
repository_project
@project
||=
Project
.
where_full_path_in
(
components
.
first
(
3
))
&
.
first
end
def
repository_name
return
unless
repository_project
@name
.
remove
(
%r(^?
#{
Regexp
.
escape
(
repository_project
.
full_path
)
}
/?)
)
end
end
end
spec/lib/container_registry/path_spec.rb
View file @
bdc1e1b9
...
...
@@ -114,6 +114,49 @@ describe ContainerRegistry::Path do
end
describe
'#repository_name'
do
pending
'returns a correct name'
context
'when project does not exist'
do
let
(
:name
)
{
'some/name'
}
it
'returns nil'
do
expect
(
path
.
repository_name
).
to
be_nil
end
end
context
'when project exists'
do
let
(
:group
)
{
create
(
:group
,
path:
'some_group'
)
}
let
(
:project
)
do
create
(
:empty_project
,
group:
group
,
name:
'some_project'
)
end
before
do
allow
(
path
).
to
receive
(
:repository_project
)
.
and_return
(
project
)
end
context
'when project path equal repository path'
do
let
(
:name
)
{
'some_group/some_project'
}
it
'returns an empty string'
do
expect
(
path
.
repository_name
).
to
eq
''
end
end
context
'when repository path has one additional level'
do
let
(
:name
)
{
'some_group/some_project/repository'
}
it
'returns a correct repository name'
do
expect
(
path
.
repository_name
).
to
eq
'repository'
end
end
context
'when repository path has two additional levels'
do
let
(
:name
)
{
'some_group/some_project/repository/image'
}
it
'returns a correct repository name'
do
expect
(
path
.
repository_name
).
to
eq
'repository/image'
end
end
end
end
end
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