Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7c51d5ef
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,发现更多精彩内容 >>
提交
7c51d5ef
编写于
3月 20, 2016
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix some specs
上级
3058a8fa
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
20 addition
and
61 deletion
+20
-61
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+0
-1
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+1
-1
app/models/project.rb
app/models/project.rb
+2
-8
app/views/events/event/_common.html.haml
app/views/events/event/_common.html.haml
+1
-1
db/migrate/20160320204112_index_namespaces_on_visibility_level.rb
...te/20160320204112_index_namespaces_on_visibility_level.rb
+5
-0
db/schema.rb
db/schema.rb
+1
-0
features/steps/shared/group.rb
features/steps/shared/group.rb
+2
-2
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+0
-40
spec/lib/banzai/filter/redactor_filter_spec.rb
spec/lib/banzai/filter/redactor_filter_spec.rb
+2
-2
spec/models/project_security_spec.rb
spec/models/project_security_spec.rb
+5
-5
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+1
-1
未找到文件。
app/controllers/admin/projects_controller.rb
浏览文件 @
7c51d5ef
class
Admin::ProjectsController
<
Admin
::
ApplicationController
before_action
:project
,
only:
[
:show
,
:transfer
]
before_action
:group
,
only:
[
:show
,
:transfer
]
before_action
:repository
,
only:
[
:show
,
:transfer
]
def
index
@projects
=
Project
.
all
...
...
app/controllers/projects/application_controller.rb
浏览文件 @
7c51d5ef
...
...
@@ -67,7 +67,7 @@ class Projects::ApplicationController < ApplicationController
end
def
require_non_empty_project
redirect_to
@project
if
@project
.
empty_repo?
redirect_to
namespace_project_path
(
@project
.
namespace
,
@project
)
if
@project
.
empty_repo?
end
def
require_branch_head
...
...
app/models/project.rb
浏览文件 @
7c51d5ef
...
...
@@ -246,10 +246,6 @@ class Project < ActiveRecord::Base
end
class
<<
self
def
public_and_internal_levels
[
Project
::
PUBLIC
,
Project
::
INTERNAL
]
end
def
abandoned
where
(
'projects.last_activity_at < ?'
,
6
.
months
.
ago
)
end
...
...
@@ -976,11 +972,9 @@ class Project < ActiveRecord::Base
end
def
visibility_level_allowed_as_fork?
(
level
=
self
.
visibility_level
)
return
true
unless
forked?
&&
forked_project_link
.
forked_from_project_id
.
present?
return
true
unless
forked?
from_project
=
self
.
forked_from_project
from_project
||=
Project
.
find
(
forked_project_link
.
forked_from_project_id
)
Gitlab
::
VisibilityLevel
.
allowed_fork_levels
(
from_project
.
visibility_level
).
include?
(
level
)
Gitlab
::
VisibilityLevel
.
allowed_fork_levels
(
forked_from_project
.
visibility_level
).
include?
(
level
)
end
def
visibility_level_allowed_by_group?
(
level
=
self
.
visibility_level
)
...
...
app/views/events/event/_common.html.haml
浏览文件 @
7c51d5ef
...
...
@@ -4,7 +4,7 @@
=
event_action_name
(
event
)
-
if
event
.
target
%strong
=
link_to
event
.
target
.
to_reference
,
[
event
.
project
.
namespace
.
becomes
(
Namespace
),
event
.
project
,
event
.
target
]
%strong
=
link_to
event
.
target
.
reference_link_text
,
[
event
.
project
.
namespace
.
becomes
(
Namespace
),
event
.
project
,
event
.
target
]
=
event_preposition
(
event
)
...
...
db/migrate/20160320204112_index_namespaces_on_visibility_level.rb
0 → 100644
浏览文件 @
7c51d5ef
class
IndexNamespacesOnVisibilityLevel
<
ActiveRecord
::
Migration
def
change
add_index
:namespaces
,
:visibility_level
end
end
db/schema.rb
浏览文件 @
7c51d5ef
...
...
@@ -601,6 +601,7 @@ ActiveRecord::Schema.define(version: 20160316204731) do
add_index
"namespaces"
,
[
"path"
],
name:
"index_namespaces_on_path"
,
unique:
true
,
using: :btree
add_index
"namespaces"
,
[
"path"
],
name:
"index_namespaces_on_path_trigram"
,
using: :gin
,
opclasses:
{
"path"
=>
"gin_trgm_ops"
}
add_index
"namespaces"
,
[
"type"
],
name:
"index_namespaces_on_type"
,
using: :btree
add_index
"namespaces"
,
[
"visibility_level"
],
name:
"index_namespaces_on_visibility_level"
,
using: :btree
create_table
"notes"
,
force: :cascade
do
|
t
|
t
.
text
"note"
...
...
features/steps/shared/group.rb
浏览文件 @
7c51d5ef
...
...
@@ -38,7 +38,7 @@ module SharedGroup
def
is_member_of
(
username
,
groupname
,
role
)
@project_count
||=
0
user
=
User
.
find_by
(
name:
username
)
||
create
(
:user
,
name:
username
)
group
=
Group
.
find_by
(
name:
groupname
)
||
create
(
:group
,
name:
groupname
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
group
=
Group
.
find_by
(
name:
groupname
)
||
create
(
:group
,
name:
groupname
)
group
.
add_user
(
user
,
role
)
project
||=
create
(
:project
,
namespace:
group
,
path:
"project
#{
@project_count
}
"
)
create
(
:closed_issue_event
,
project:
project
)
...
...
@@ -47,6 +47,6 @@ module SharedGroup
end
def
owned_group
@owned_group
||=
Group
.
find_by
(
name:
"Owned"
,
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
@owned_group
||=
Group
.
find_by
(
name:
"Owned"
)
end
end
spec/controllers/application_controller_spec.rb
浏览文件 @
7c51d5ef
...
...
@@ -30,44 +30,4 @@ describe ApplicationController do
controller
.
send
(
:check_password_expiration
)
end
end
describe
'check labels authorization'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:controller
)
{
ApplicationController
.
new
}
before
do
project
.
team
<<
[
user
,
:guest
]
allow
(
controller
).
to
receive
(
:current_user
).
and_return
(
user
)
allow
(
controller
).
to
receive
(
:project
).
and_return
(
project
)
end
it
'should succeed if issues and MRs are enabled'
do
project
.
issues_enabled
=
true
project
.
merge_requests_enabled
=
true
controller
.
send
(
:authorize_read_label!
)
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should succeed if issues are enabled, MRs are disabled'
do
project
.
issues_enabled
=
true
project
.
merge_requests_enabled
=
false
controller
.
send
(
:authorize_read_label!
)
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should succeed if issues are disabled, MRs are enabled'
do
project
.
issues_enabled
=
false
project
.
merge_requests_enabled
=
true
controller
.
send
(
:authorize_read_label!
)
expect
(
response
.
status
).
to
eq
(
200
)
end
it
'should fail if issues and MRs are disabled'
do
project
.
issues_enabled
=
false
project
.
merge_requests_enabled
=
false
expect
(
controller
).
to
receive
(
:access_denied!
)
controller
.
send
(
:authorize_read_label!
)
end
end
end
spec/lib/banzai/filter/redactor_filter_spec.rb
浏览文件 @
7c51d5ef
...
...
@@ -119,7 +119,7 @@ describe Banzai::Filter::RedactorFilter, lib: true do
context
'with data-group'
do
it
'removes unpermitted Group references'
do
user
=
create
(
:user
)
group
=
create
(
:group
)
group
=
create
(
:group
,
:private
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
doc
=
filter
(
link
,
current_user:
user
)
...
...
@@ -129,7 +129,7 @@ describe Banzai::Filter::RedactorFilter, lib: true do
it
'allows permitted Group references'
do
user
=
create
(
:user
)
group
=
create
(
:group
)
group
=
create
(
:group
,
:private
)
group
.
add_developer
(
user
)
link
=
reference_link
(
group:
group
.
id
,
reference_filter:
'UserReferenceFilter'
)
...
...
spec/models/project_security_spec.rb
浏览文件 @
7c51d5ef
...
...
@@ -18,11 +18,11 @@ describe Project, models: true do
let
(
:report_actions
)
{
Ability
.
project_report_rules
}
let
(
:dev_actions
)
{
Ability
.
project_dev_rules
}
let
(
:master_actions
)
{
Ability
.
project_master_rules
}
let
(
:
admin_actions
)
{
Ability
.
project_admin
_rules
}
let
(
:
owner_actions
)
{
Ability
.
project_owner
_rules
}
describe
"Non member rules"
do
it
"should deny for non-project users any actions"
do
admin
_actions
.
each
do
|
action
|
owner
_actions
.
each
do
|
action
|
expect
(
@abilities
.
allowed?
(
@u1
,
action
,
@p1
)).
to
be_falsey
end
end
...
...
@@ -90,20 +90,20 @@ describe Project, models: true do
end
end
describe
"
Admin
Rules"
do
describe
"
Owner
Rules"
do
before
do
@p1
.
project_members
.
create
(
project:
@p1
,
user:
@u2
,
access_level:
ProjectMember
::
DEVELOPER
)
@p1
.
project_members
.
create
(
project:
@p1
,
user:
@u3
,
access_level:
ProjectMember
::
MASTER
)
end
it
"should deny for masters admin-specific actions"
do
[
admin
_actions
-
master_actions
].
each
do
|
action
|
[
owner
_actions
-
master_actions
].
each
do
|
action
|
expect
(
@abilities
.
allowed?
(
@u2
,
action
,
@p1
)).
to
be_falsey
end
end
it
"should allow for project owner any admin actions"
do
admin
_actions
.
each
do
|
action
|
owner
_actions
.
each
do
|
action
|
expect
(
@abilities
.
allowed?
(
@u4
,
action
,
@p1
)).
to
be_truthy
end
end
...
...
spec/requests/api/groups_spec.rb
浏览文件 @
7c51d5ef
...
...
@@ -9,7 +9,7 @@ describe API::API, api: true do
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:avatar_file_path
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
}
let!
(
:group1
)
{
create
(
:group
,
avatar:
File
.
open
(
avatar_file_path
))
}
let!
(
:group2
)
{
create
(
:group
)
}
let!
(
:group2
)
{
create
(
:group
,
:private
)
}
let!
(
:project1
)
{
create
(
:project
,
namespace:
group1
)
}
let!
(
:project2
)
{
create
(
:project
,
namespace:
group2
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录