Commit 13fefb7f authored by Robert Speicher's avatar Robert Speicher

Merge branch 'ajk-reorder-designs-policies' into 'master'

Add move_design ability

See merge request gitlab-org/gitlab!37860
parents f984a0f9 3e73f6f1
...@@ -35,8 +35,13 @@ class IssuePolicy < IssuablePolicy ...@@ -35,8 +35,13 @@ class IssuePolicy < IssuablePolicy
prevent :destroy_design prevent :destroy_design
end end
rule { ~can?(:read_design) }.policy do
prevent :move_design
end
rule { locked | moved }.policy do rule { locked | moved }.policy do
prevent :create_design prevent :create_design
prevent :move_design
prevent :destroy_design prevent :destroy_design
end end
end end
......
...@@ -123,6 +123,11 @@ class ProjectPolicy < BasePolicy ...@@ -123,6 +123,11 @@ class ProjectPolicy < BasePolicy
!@subject.design_management_enabled? !@subject.design_management_enabled?
end end
with_scope :subject
condition(:moving_designs_disabled) do
!::Feature.enabled?(:reorder_designs, @subject)
end
with_scope :subject with_scope :subject
condition(:service_desk_enabled) { @subject.service_desk_enabled? } condition(:service_desk_enabled) { @subject.service_desk_enabled? }
...@@ -342,6 +347,7 @@ class ProjectPolicy < BasePolicy ...@@ -342,6 +347,7 @@ class ProjectPolicy < BasePolicy
enable :read_alert_management_alert enable :read_alert_management_alert
enable :update_alert_management_alert enable :update_alert_management_alert
enable :create_design enable :create_design
enable :move_design
enable :destroy_design enable :destroy_design
enable :read_terraform_state enable :read_terraform_state
end end
...@@ -573,6 +579,11 @@ class ProjectPolicy < BasePolicy ...@@ -573,6 +579,11 @@ class ProjectPolicy < BasePolicy
prevent :read_design_activity prevent :read_design_activity
prevent :create_design prevent :create_design
prevent :destroy_design prevent :destroy_design
prevent :move_design
end
rule { moving_designs_disabled }.policy do
prevent :move_design
end end
rule { read_package_registry_deploy_token }.policy do rule { read_package_registry_deploy_token }.policy do
......
...@@ -5,7 +5,7 @@ RSpec.describe DesignManagement::DesignPolicy do ...@@ -5,7 +5,7 @@ RSpec.describe DesignManagement::DesignPolicy do
include DesignManagementTestHelpers include DesignManagementTestHelpers
let(:guest_design_abilities) { %i[read_design] } let(:guest_design_abilities) { %i[read_design] }
let(:developer_design_abilities) { %i[create_design destroy_design] } let(:developer_design_abilities) { %i[create_design destroy_design move_design] }
let(:design_abilities) { guest_design_abilities + developer_design_abilities } let(:design_abilities) { guest_design_abilities + developer_design_abilities }
let_it_be(:guest) { create(:user) } let_it_be(:guest) { create(:user) }
...@@ -131,6 +131,17 @@ RSpec.describe DesignManagement::DesignPolicy do ...@@ -131,6 +131,17 @@ RSpec.describe DesignManagement::DesignPolicy do
it_behaves_like "design abilities available for members" it_behaves_like "design abilities available for members"
context 'when reorder_designs is not enabled' do
before do
stub_feature_flags(reorder_designs: false)
end
let(:current_user) { developer }
it { is_expected.to be_allowed(*(developer_design_abilities - [:move_design])) }
it { is_expected.to be_disallowed(:move_design) }
end
context "for guests in private projects" do context "for guests in private projects" do
let_it_be(:project) { create(:project, :private) } let_it_be(:project) { create(:project, :private) }
let(:current_user) { guest } let(:current_user) { guest }
......
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