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
60cdd2bc
Commit
60cdd2bc
authored
Mar 31, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for container repository factory method
parent
a7466af3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
10 deletions
+45
-10
app/models/container_repository.rb
app/models/container_repository.rb
+1
-1
app/services/auth/container_registry_authentication_service.rb
...ervices/auth/container_registry_authentication_service.rb
+1
-1
spec/models/container_repository_spec.rb
spec/models/container_repository_spec.rb
+43
-8
No files found.
app/models/container_repository.rb
View file @
60cdd2bc
...
...
@@ -58,7 +58,7 @@ class ContainerRepository < ActiveRecord::Base
end
end
def
self
.
create_from_path
(
path
)
def
self
.
create_from_path
!
(
path
)
self
.
create
(
project:
path
.
repository_project
,
name:
path
.
repository_name
)
end
...
...
app/services/auth/container_registry_authentication_service.rb
View file @
60cdd2bc
...
...
@@ -94,7 +94,7 @@ module Auth
return
if
path
.
has_repository?
return
unless
actions
.
include?
(
'push'
)
ContainerRepository
.
create_from_path
(
path
)
ContainerRepository
.
create_from_path
!
(
path
)
end
def
can_access?
(
requested_project
,
requested_action
)
...
...
spec/models/container_repository_spec.rb
View file @
60cdd2bc
...
...
@@ -85,28 +85,63 @@ describe ContainerRepository do
end
end
describe
'#from_repository_path'
do
describe
'.create_from_path!'
do
let
(
:repository
)
do
described_class
.
create_from_path!
(
ContainerRegistry
::
Path
.
new
(
path
))
end
let
(
:repository_path
)
{
ContainerRegistry
::
Path
.
new
(
path
)
}
context
'when received multi-level repository path'
do
let
(
:repository
)
do
described_class
.
from_repository_path
(
'group/test/some/image/name'
)
end
let
(
:path
)
{
project
.
full_path
+
'/some/image'
}
pending
'fabricates object within
a correct project'
do
it
'fabricates repository assigned to
a correct project'
do
expect
(
repository
.
project
).
to
eq
project
end
pending
'it fabricates project
with a correct name'
do
expect
(
repository
.
name
).
to
eq
'some/image
/name
'
it
'fabricates repository
with a correct name'
do
expect
(
repository
.
name
).
to
eq
'some/image'
end
end
context
'when path contains too many nodes'
do
context
'when path is too long'
do
let
(
:path
)
do
project
.
full_path
+
'/a/b/c/d/e/f/g/h/i/j/k/l/n/o/p/s/t/u/x/y/z'
end
it
'does not create repository and raises error'
do
expect
{
repository
}.
to
raise_error
(
ContainerRegistry
::
Path
::
InvalidRegistryPathError
)
end
end
context
'when received multi-level repository with nested groups'
do
let
(
:group
)
{
create
(
:group
,
:nested
,
name:
'nested'
)
}
let
(
:path
)
{
project
.
full_path
+
'/some/image'
}
it
'fabricates repository assigned to a correct project'
do
expect
(
repository
.
project
).
to
eq
project
end
it
'fabricates repository with a correct name'
do
expect
(
repository
.
name
).
to
eq
'some/image'
end
it
'has path including a nested group'
do
expect
(
repository
.
path
).
to
include
'nested/test/some/image'
end
end
context
'when received root repository path'
do
let
(
:path
)
{
project
.
full_path
}
it
'fabricates repository assigned to a correct project'
do
expect
(
repository
.
project
).
to
eq
project
end
it
'fabricates repository with an empty name'
do
expect
(
repository
.
name
).
to
be_empty
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