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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
c64c1060
Commit
c64c1060
authored
Feb 04, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update ability model after comments
parent
6fea7c38
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
24 deletions
+15
-24
app/models/ability.rb
app/models/ability.rb
+15
-24
No files found.
app/models/ability.rb
View file @
c64c1060
...
@@ -5,22 +5,18 @@ class Ability
...
@@ -5,22 +5,18 @@ class Ability
return
[]
unless
user
.
is_a?
(
User
)
return
[]
unless
user
.
is_a?
(
User
)
return
[]
if
user
.
blocked?
return
[]
if
user
.
blocked?
# We check with `is_a?`, because CommitStatus uses inheritance
case
subject
if
subject
.
is_a?
(
CommitStatus
)
when
CommitStatus
then
commit_status_abilities
(
user
,
subject
)
return
commit_status_abilities
(
user
,
subject
)
when
Project
then
project_abilities
(
user
,
subject
)
end
when
Issue
then
issue_abilities
(
user
,
subject
)
when
Note
then
note_abilities
(
user
,
subject
)
case
subject
.
class
.
name
when
ProjectSnippet
then
project_snippet_abilities
(
user
,
subject
)
when
"Project"
then
project_abilities
(
user
,
subject
)
when
PersonalSnippet
then
personal_snippet_abilities
(
user
,
subject
)
when
"Issue"
then
issue_abilities
(
user
,
subject
)
when
MergeRequest
then
merge_request_abilities
(
user
,
subject
)
when
"Note"
then
note_abilities
(
user
,
subject
)
when
Group
then
group_abilities
(
user
,
subject
)
when
"ProjectSnippet"
then
project_snippet_abilities
(
user
,
subject
)
when
Namespace
then
namespace_abilities
(
user
,
subject
)
when
"PersonalSnippet"
then
personal_snippet_abilities
(
user
,
subject
)
when
GroupMember
then
group_member_abilities
(
user
,
subject
)
when
"MergeRequest"
then
merge_request_abilities
(
user
,
subject
)
when
ProjectMember
then
project_member_abilities
(
user
,
subject
)
when
"Group"
then
group_abilities
(
user
,
subject
)
when
"Namespace"
then
namespace_abilities
(
user
,
subject
)
when
"GroupMember"
then
group_member_abilities
(
user
,
subject
)
when
"ProjectMember"
then
project_member_abilities
(
user
,
subject
)
else
[]
else
[]
end
.
concat
(
global_abilities
(
user
))
end
.
concat
(
global_abilities
(
user
))
end
end
...
@@ -130,10 +126,8 @@ class Ability
...
@@ -130,10 +126,8 @@ class Ability
if
project
.
public?
||
project
.
internal?
if
project
.
public?
||
project
.
internal?
rules
.
push
(
*
public_project_rules
)
rules
.
push
(
*
public_project_rules
)
end
# Allow to read builds for internal projects
# Allow to read builds for internal projects
if
project
.
public?
||
project
.
internal?
rules
<<
:read_build
if
project
.
public_builds?
rules
<<
:read_build
if
project
.
public_builds?
end
end
...
@@ -416,11 +410,8 @@ class Ability
...
@@ -416,11 +410,8 @@ class Ability
def
filter_build_abilities
(
rules
)
def
filter_build_abilities
(
rules
)
# If we can't read build we should also not have that
# If we can't read build we should also not have that
# ability when looking at this in context of commit_status
# ability when looking at this in context of commit_status
unless
rules
.
include?
(
:read_build
)
%w(read create update admin)
.
each
do
|
rule
|
rules
-=
[
:read_commit_status
]
rules
-=
[
:"
#{
rule
}
_commit_status"
]
unless
rules
.
include?
(
:"
#{
rule
}
_build"
)
end
unless
rules
.
include?
(
:update_build
)
rules
-=
[
:update_commit_status
]
end
end
rules
rules
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