Commit 7e253b22 authored by Tan Le's avatar Tan Le

Remove unused merge request policies on project

Recent work on regulating project-level merge request approvals settings
using compliance label has removed the need to utilize instance-level
settings in controlling the modification permission.

Some internal conditions in the project policies are also consolidated.
parent 7a33f641
...@@ -33,27 +33,6 @@ module EE ...@@ -33,27 +33,6 @@ module EE
!PushRule.global&.commit_committer_check !PushRule.global&.commit_committer_check
end end
with_scope :global
condition(:owner_cannot_modify_approvers_rules) do
License.feature_available?(:admin_merge_request_approvers_rules) &&
::Gitlab::CurrentSettings.current_application_settings
.disable_overriding_approvers_per_merge_request
end
with_scope :global
condition(:owner_cannot_modify_merge_request_author_setting) do
License.feature_available?(:admin_merge_request_approvers_rules) &&
::Gitlab::CurrentSettings.current_application_settings
.prevent_merge_requests_author_approval
end
with_scope :global
condition(:owner_cannot_modify_merge_request_committer_setting) do
License.feature_available?(:admin_merge_request_approvers_rules) &&
::Gitlab::CurrentSettings.current_application_settings
.prevent_merge_requests_committers_approval
end
with_scope :subject with_scope :subject
condition(:regulated_merge_request_approval_settings) do condition(:regulated_merge_request_approval_settings) do
License.feature_available?(:admin_merge_request_approvers_rules) && License.feature_available?(:admin_merge_request_approvers_rules) &&
...@@ -64,18 +43,6 @@ module EE ...@@ -64,18 +43,6 @@ module EE
@subject.feature_available?(:project_merge_request_analytics) @subject.feature_available?(:project_merge_request_analytics)
end end
condition(:cannot_modify_approvers_rules) do
regulated_merge_request_approval_settings?
end
condition(:cannot_modify_merge_request_author_setting) do
regulated_merge_request_approval_settings?
end
condition(:cannot_modify_merge_request_committer_setting) do
regulated_merge_request_approval_settings?
end
with_scope :subject with_scope :subject
condition(:group_push_rules_enabled) do condition(:group_push_rules_enabled) do
@subject.group && ::Feature.enabled?(:group_push_rules, @subject.group.root_ancestor) @subject.group && ::Feature.enabled?(:group_push_rules, @subject.group.root_ancestor)
...@@ -267,7 +234,6 @@ module EE ...@@ -267,7 +234,6 @@ module EE
enable :update_approvers enable :update_approvers
enable :admin_feature_flags_client enable :admin_feature_flags_client
enable :modify_approvers_rules enable :modify_approvers_rules
enable :modify_approvers_list
enable :modify_auto_fix_setting enable :modify_auto_fix_setting
enable :modify_merge_request_author_setting enable :modify_merge_request_author_setting
enable :modify_merge_request_committer_setting enable :modify_merge_request_committer_setting
...@@ -346,16 +312,9 @@ module EE ...@@ -346,16 +312,9 @@ module EE
prevent :read_project prevent :read_project
end end
rule { cannot_modify_approvers_rules }.policy do rule { regulated_merge_request_approval_settings }.policy do
prevent :modify_approvers_rules prevent :modify_approvers_rules
prevent :modify_approvers_list
end
rule { cannot_modify_merge_request_author_setting }.policy do
prevent :modify_merge_request_author_setting prevent :modify_merge_request_author_setting
end
rule { cannot_modify_merge_request_committer_setting }.policy do
prevent :modify_merge_request_committer_setting prevent :modify_merge_request_committer_setting
end end
......
...@@ -1237,7 +1237,7 @@ RSpec.describe ProjectPolicy do ...@@ -1237,7 +1237,7 @@ RSpec.describe ProjectPolicy do
end end
end end
context 'with merge request approvers not available in license' do context 'with merge request approvers rules not available in license' do
where(:role, :regulated_setting, :admin_mode, :allowed) do where(:role, :regulated_setting, :admin_mode, :allowed) do
:guest | true | nil | false :guest | true | nil | false
:reporter | true | nil | false :reporter | true | nil | false
...@@ -1268,32 +1268,22 @@ RSpec.describe ProjectPolicy do ...@@ -1268,32 +1268,22 @@ RSpec.describe ProjectPolicy do
describe ':modify_approvers_rules' do describe ':modify_approvers_rules' do
it_behaves_like 'merge request rules' do it_behaves_like 'merge request rules' do
let(:setting_name) { :disable_overriding_approvers_per_merge_request }
let(:policy) { :modify_approvers_rules } let(:policy) { :modify_approvers_rules }
end end
end end
describe ':modify_merge_request_author_setting' do describe ':modify_merge_request_author_setting' do
it_behaves_like 'merge request rules' do it_behaves_like 'merge request rules' do
let(:setting_name) { :prevent_merge_requests_author_approval }
let(:policy) { :modify_merge_request_author_setting } let(:policy) { :modify_merge_request_author_setting }
end end
end end
describe ':modify_merge_request_committer_setting' do describe ':modify_merge_request_committer_setting' do
it_behaves_like 'merge request rules' do it_behaves_like 'merge request rules' do
let(:setting_name) { :prevent_merge_requests_committers_approval }
let(:policy) { :modify_merge_request_committer_setting } let(:policy) { :modify_merge_request_committer_setting }
end end
end end
describe ':modify_approvers_list' do
it_behaves_like 'merge request rules' do
let(:setting_name) { :disable_overriding_approvers_per_merge_request }
let(:policy) { :modify_approvers_list }
end
end
it_behaves_like 'resource with requirement permissions' do it_behaves_like 'resource with requirement permissions' do
let(:resource) { project } let(:resource) { project }
end end
......
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