Commit c00d3357 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'move-policy-prepends' into 'master'

Move EE prepend/include to the end of policies

See merge request gitlab-org/gitlab-ee!8204
parents 332cfd2f b59af5fc
......@@ -3,8 +3,6 @@
require_dependency 'declarative_policy'
class BasePolicy < DeclarativePolicy::Base
prepend EE::BasePolicy
desc "User is an instance admin"
with_options scope: :user, score: 0
condition(:admin) { @user&.admin? }
......@@ -23,3 +21,5 @@ class BasePolicy < DeclarativePolicy::Base
# This is prevented in some cases in `gitlab-ee`
rule { default }.enable :read_cross_project
end
BasePolicy.prepend(EE::BasePolicy)
......@@ -2,8 +2,6 @@
module Ci
class BuildPolicy < CommitStatusPolicy
prepend EE::Ci::BuildPolicy
condition(:protected_ref) do
access = ::Gitlab::UserAccess.new(@user, project: @subject.project)
......@@ -46,3 +44,5 @@ module Ci
rule { can?(:update_build) & terminal }.enable :create_build_terminal
end
end
Ci::BuildPolicy.prepend(EE::Ci::BuildPolicy)
......@@ -6,8 +6,6 @@
module PolicyActor
extend ActiveSupport::Concern
prepend EE::PolicyActor
def blocked?
false
end
......@@ -36,3 +34,5 @@ module PolicyActor
false
end
end
PolicyActor.prepend(EE::PolicyActor)
# frozen_string_literal: true
class EnvironmentPolicy < BasePolicy
prepend EE::EnvironmentPolicy
delegate { @subject.project }
condition(:stop_with_deployment_allowed) do
......@@ -16,3 +14,5 @@ class EnvironmentPolicy < BasePolicy
rule { stop_with_deployment_allowed | stop_with_update_allowed }.enable :stop_environment
end
EnvironmentPolicy.prepend(EE::EnvironmentPolicy)
# frozen_string_literal: true
class GlobalPolicy < BasePolicy
prepend EE::GlobalPolicy
desc "User is blocked"
with_options scope: :user, score: 0
condition(:blocked) { @user&.blocked? }
......@@ -75,3 +73,5 @@ class GlobalPolicy < BasePolicy
enable :update_custom_attribute
end
end
GlobalPolicy.prepend(EE::GlobalPolicy)
# frozen_string_literal: true
class GroupPolicy < BasePolicy
prepend EE::GroupPolicy
desc "Group is public"
with_options scope: :subject, score: 0
condition(:public_group) { @subject.public? }
......@@ -110,3 +108,5 @@ class GroupPolicy < BasePolicy
@access_level ||= @subject.max_member_access_for_user(@user)
end
end
GroupPolicy.prepend(EE::GroupPolicy)
# frozen_string_literal: true
class MergeRequestPolicy < IssuablePolicy
prepend EE::MergeRequestPolicy
end
MergeRequestPolicy.prepend(EE::MergeRequestPolicy)
......@@ -2,8 +2,6 @@
class ProjectPolicy < BasePolicy
extend ClassMethods
prepend EE::ProjectPolicy
READONLY_FEATURES_WHEN_ARCHIVED = %i[
issue
list
......@@ -442,3 +440,5 @@ class ProjectPolicy < BasePolicy
@subject
end
end
ProjectPolicy.prepend(EE::ProjectPolicy)
# frozen_string_literal: true
class ProtectedBranchPolicy < BasePolicy
prepend EE::ProtectedBranchPolicy
delegate { @subject.project }
rule { can?(:admin_project) }.policy do
......@@ -11,3 +9,5 @@ class ProtectedBranchPolicy < BasePolicy
enable :destroy_protected_branch
end
end
ProtectedBranchPolicy.prepend(EE::ProtectedBranchPolicy)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment