Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
60cdd2bc
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
60cdd2bc
编写于
3月 31, 2017
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add specs for container repository factory method
上级
a7466af3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
10 deletion
+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
未找到文件。
app/models/container_repository.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录