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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
4074283d
Commit
4074283d
authored
Apr 05, 2018
by
Douwe Maan
Committed by
Bob Van Landuyt
Apr 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Block EE-specific write abilities when project is archived
parent
036af7d1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
17 deletions
+29
-17
app/policies/project_policy.rb
app/policies/project_policy.rb
+16
-16
ee/app/policies/ee/project_policy.rb
ee/app/policies/ee/project_policy.rb
+12
-0
spec/policies/project_policy_spec.rb
spec/policies/project_policy_spec.rb
+1
-1
No files found.
app/policies/project_policy.rb
View file @
4074283d
class
ProjectPolicy
<
BasePolicy
def
self
.
create_read_update_admin_destroy
(
name
)
[
:"read_
#{
name
}
"
,
*
create_update_admin_destroy
(
name
)
]
end
def
self
.
create_update_admin_destroy
(
name
)
[
:"create_
#{
name
}
"
,
:"update_
#{
name
}
"
,
:"admin_
#{
name
}
"
,
:"destroy_
#{
name
}
"
]
end
prepend
EE
::
ProjectPolicy
READONLY_FEATURES_WHEN_ARCHIVED
=
%i[
...
...
@@ -22,22 +38,6 @@ class ProjectPolicy < BasePolicy
cluster
]
.
freeze
def
self
.
create_read_update_admin_destroy
(
name
)
[
:"read_
#{
name
}
"
,
*
create_update_admin_destroy
(
name
)
]
end
def
self
.
create_update_admin_destroy
(
name
)
[
:"create_
#{
name
}
"
,
:"update_
#{
name
}
"
,
:"admin_
#{
name
}
"
,
:"destroy_
#{
name
}
"
]
end
desc
"User is a project owner"
condition
:owner
do
(
project
.
owner
.
present?
&&
project
.
owner
==
@user
)
||
...
...
ee/app/policies/ee/project_policy.rb
View file @
4074283d
...
...
@@ -2,6 +2,12 @@ module EE
module
ProjectPolicy
extend
ActiveSupport
::
Concern
READONLY_FEATURES_WHEN_ARCHIVED
=
%i[
board
issue_link
approvers
]
.
freeze
prepended
do
with_scope
:subject
condition
(
:service_desk_enabled
)
{
@subject
.
service_desk_enabled?
}
...
...
@@ -125,6 +131,12 @@ module EE
prevent
:master_access
prevent
:owner_access
end
rule
{
archived
}.
policy
do
READONLY_FEATURES_WHEN_ARCHIVED
.
each
do
|
feature
|
prevent
(
*::
ProjectPolicy
.
create_update_admin_destroy
(
feature
))
end
end
end
end
end
spec/policies/project_policy_spec.rb
View file @
4074283d
...
...
@@ -140,7 +140,7 @@ describe ProjectPolicy do
let
(
:feature_write_abilities
)
do
described_class
::
READONLY_FEATURES_WHEN_ARCHIVED
.
flat_map
do
|
feature
|
described_class
.
create_update_admin_destroy
(
feature
)
end
end
+
additional_reporter_permissions
+
additional_master_permissions
end
let
(
:other_write_abilities
)
do
...
...
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