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
97c6cf59
Commit
97c6cf59
authored
Apr 04, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap method names in containe registry path class
parent
7cf91f7b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
17 deletions
+17
-17
lib/container_registry/path.rb
lib/container_registry/path.rb
+8
-8
spec/lib/container_registry/path_spec.rb
spec/lib/container_registry/path_spec.rb
+9
-9
No files found.
lib/container_registry/path.rb
View file @
97c6cf59
...
...
@@ -18,19 +18,19 @@ module ContainerRegistry
def
valid?
@path
=~
Gitlab
::
Regex
.
container_repository_name_regex
&&
node
s
.
size
>
1
&&
node
s
.
size
<
Namespace
::
NUMBER_OF_ANCESTORS_ALLOWED
component
s
.
size
>
1
&&
component
s
.
size
<
Namespace
::
NUMBER_OF_ANCESTORS_ALLOWED
end
def
node
s
@
node
s
||=
@path
.
to_s
.
split
(
'/'
)
def
component
s
@
component
s
||=
@path
.
to_s
.
split
(
'/'
)
end
def
component
s
def
node
s
raise
InvalidRegistryPathError
unless
valid?
@
components
||=
node
s
.
size
.
downto
(
2
).
map
do
|
length
|
node
s
.
take
(
length
).
join
(
'/'
)
@
nodes
||=
component
s
.
size
.
downto
(
2
).
map
do
|
length
|
component
s
.
take
(
length
).
join
(
'/'
)
end
end
...
...
@@ -50,7 +50,7 @@ module ContainerRegistry
end
def
repository_project
@project
||=
Project
.
where_full_path_in
(
component
s
.
first
(
3
)).
first
@project
||=
Project
.
where_full_path_in
(
node
s
.
first
(
3
)).
first
end
def
repository_name
...
...
spec/lib/container_registry/path_spec.rb
View file @
97c6cf59
...
...
@@ -3,20 +3,20 @@ require 'spec_helper'
describe
ContainerRegistry
::
Path
do
subject
{
described_class
.
new
(
path
)
}
describe
'#
node
s'
do
describe
'#
component
s'
do
let
(
:path
)
{
'path/to/some/project'
}
it
'splits
elem
ents by a forward slash'
do
expect
(
subject
.
node
s
).
to
eq
%w[path to some project]
it
'splits
compon
ents by a forward slash'
do
expect
(
subject
.
component
s
).
to
eq
%w[path to some project]
end
end
describe
'#
component
s'
do
describe
'#
node
s'
do
context
'when repository path is valid'
do
let
(
:path
)
{
'path/to/some/project'
}
it
'return all project
-like components
in reverse order'
do
expect
(
subject
.
component
s
).
to
eq
%w[path/to/some/project
it
'return all project
path like node
in reverse order'
do
expect
(
subject
.
node
s
).
to
eq
%w[path/to/some/project
path/to/some
path/to]
end
...
...
@@ -26,7 +26,7 @@ describe ContainerRegistry::Path do
let
(
:path
)
{
''
}
it
'rasises en error'
do
expect
{
subject
.
component
s
}
expect
{
subject
.
node
s
}
.
to
raise_error
described_class
::
InvalidRegistryPathError
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