Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
15ba6ea1
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,发现更多精彩内容 >>
提交
15ba6ea1
编写于
9月 24, 2014
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor Gitlab::GitAccess tests
上级
3aa7132a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
119 deletion
+66
-119
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+66
-119
未找到文件。
spec/lib/gitlab/git_access_spec.rb
浏览文件 @
15ba6ea1
...
...
@@ -49,132 +49,79 @@ describe Gitlab::GitAccess do
end
describe
'push_allowed?'
do
describe
'master permissions'
do
before
{
project
.
team
<<
[
user
,
:master
]
}
context
'push to new branch'
do
subject
{
access
.
push_allowed?
(
user
,
project
,
new_branch_changes
)
}
it
{
should
be_true
}
end
context
'push to master branch'
do
subject
{
access
.
push_allowed?
(
user
,
project
,
master_changes
)
}
it
{
should
be_true
}
end
context
'push to protected branch'
do
before
{
protect_master
}
subject
{
access
.
push_allowed?
(
user
,
project
,
master_changes
)
}
it
{
should
be_true
}
end
context
'remove protected branch'
do
before
{
protect_master
}
subject
{
access
.
push_allowed?
(
user
,
project
,
remove_master_changes
)
}
it
{
should
be_false
}
end
context
'push to existing tag'
do
subject
{
access
.
push_allowed?
(
user
,
project
,
tag_changes
)
}
it
{
should
be_true
}
end
context
'push new tag'
do
subject
{
access
.
push_allowed?
(
user
,
project
,
new_tag_changes
)
}
it
{
should
be_true
}
end
context
'push new tag and protected branch'
do
before
{
protect_master
}
subject
{
access
.
push_allowed?
(
user
,
project
,
[
new_tag_changes
,
master_changes
])
}
it
{
should
be_true
}
end
def
protect_feature_branch
create
(
:protected_branch
,
name:
'feature'
,
project:
project
)
end
describe
'developer permissions'
do
before
{
project
.
team
<<
[
user
,
:developer
]
}
context
'push to new branch'
do
subject
{
access
.
push_allowed?
(
user
,
project
,
new_branch_changes
)
}
it
{
should
be_true
}
end
context
'push to master branch'
do
subject
{
access
.
push_allowed?
(
user
,
project
,
master_changes
)
}
it
{
should
be_true
}
end
context
'push to protected branch'
do
before
{
protect_master
}
subject
{
access
.
push_allowed?
(
user
,
project
,
master_changes
)
}
it
{
should
be_false
}
end
context
'remove protected branch'
do
before
{
protect_master
}
subject
{
access
.
push_allowed?
(
user
,
project
,
remove_master_changes
)
}
it
{
should
be_false
}
end
def
changes
{
push_new_branch:
'000000000 570e7b2ab refs/heads/wow'
,
push_master:
'6f6d7e7ed 570e7b2ab refs/heads/master'
,
push_protected_branch:
'6f6d7e7ed 570e7b2ab refs/heads/feature'
,
push_remove_protected_branch:
'570e7b2ab 000000000 refs/heads/feature'
,
push_tag:
'6f6d7e7ed 570e7b2ab refs/tags/v1.0.0'
,
push_new_tag:
'000000000 570e7b2ab refs/tags/v7.8.9'
,
push_all:
[
'6f6d7e7ed 570e7b2ab refs/heads/master'
,
'6f6d7e7ed 570e7b2ab refs/heads/feature'
]
}
end
context
'push to existing tag'
do
subject
{
access
.
push_allowed?
(
user
,
project
,
tag_changes
)
}
def
self
.
permissions_matrix
{
master:
{
push_new_branch:
true
,
push_master:
true
,
push_protected_branch:
true
,
push_remove_protected_branch:
false
,
push_tag:
true
,
push_new_tag:
true
,
push_all:
true
,
},
developer:
{
push_new_branch:
true
,
push_master:
true
,
push_protected_branch:
false
,
push_remove_protected_branch:
false
,
push_tag:
false
,
push_new_tag:
true
,
push_all:
false
,
},
reporter:
{
push_new_branch:
false
,
push_master:
false
,
push_protected_branch:
false
,
push_remove_protected_branch:
false
,
push_tag:
false
,
push_new_tag:
false
,
push_all:
false
,
},
guest:
{
push_new_branch:
false
,
push_master:
false
,
push_protected_branch:
false
,
push_remove_protected_branch:
false
,
push_tag:
false
,
push_new_tag:
false
,
push_all:
false
,
}
}
end
it
{
should
be_false
}
end
permissions_matrix
.
keys
.
each
do
|
role
|
describe
"
#{
role
}
access"
do
before
{
protect_feature_branch
}
before
{
project
.
team
<<
[
user
,
role
]
}
context
'push new tag'
do
subject
{
access
.
push_allowed?
(
user
,
project
,
new_tag_changes
)
}
permissions_matrix
[
role
].
each
do
|
action
,
allowed
|
context
action
do
subject
{
access
.
push_allowed?
(
user
,
project
,
changes
[
action
])
}
it
{
should
be_true
}
end
context
'push new tag and protected branch'
do
before
{
protect_master
}
subject
{
access
.
push_allowed?
(
user
,
project
,
[
new_tag_changes
,
master_changes
])
}
it
{
should
be_false
}
it
{
should
allowed
?
be_true
:
be_false
}
end
end
end
end
end
describe
'forced_push?'
do
subject
{
access
.
forced_push?
(
project
,
'111111'
,
'222222'
)
}
it
{
should
be_false
}
end
def
new_branch_changes
'000000000 570e7b2ab refs/heads/wow'
end
def
master_changes
'6f6d7e7ed 570e7b2ab refs/heads/master'
end
def
remove_master_changes
'570e7b2ab 000000000 refs/heads/master'
end
def
tag_changes
'6f6d7e7ed 570e7b2ab refs/tags/v1.0.0'
end
def
new_tag_changes
'000000000 570e7b2ab refs/tags/v7.8.9'
end
def
protect_master
create
(
:protected_branch
,
name:
'master'
,
project:
project
)
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录