diff options
Diffstat (limited to 'spec/policies/design_management')
-rw-r--r-- | spec/policies/design_management/design_policy_spec.rb | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/spec/policies/design_management/design_policy_spec.rb b/spec/policies/design_management/design_policy_spec.rb index 5a74d979ef3..117279d1638 100644 --- a/spec/policies/design_management/design_policy_spec.rb +++ b/spec/policies/design_management/design_policy_spec.rb @@ -71,6 +71,11 @@ RSpec.describe DesignManagement::DesignPolicy do end end + shared_examples_for "read-only design abilities" do + it { is_expected.to be_allowed(*guest_design_abilities) } + it { is_expected.to be_disallowed(*developer_design_abilities) } + end + shared_examples_for "design abilities available for members" do context "for owners" do let(:current_user) { owner } @@ -86,8 +91,7 @@ RSpec.describe DesignManagement::DesignPolicy do end context "when admin mode disabled" do - it { is_expected.to be_allowed(*guest_design_abilities) } - it { is_expected.to be_disallowed(*developer_design_abilities) } + it_behaves_like "read-only design abilities" end end @@ -106,16 +110,10 @@ RSpec.describe DesignManagement::DesignPolicy do context "for reporters" do let(:current_user) { reporter } - it { is_expected.to be_allowed(*guest_design_abilities) } - it { is_expected.to be_disallowed(*developer_design_abilities) } + it_behaves_like "read-only design abilities" end end - shared_examples_for "read-only design abilities" do - it { is_expected.to be_allowed(:read_design) } - it { is_expected.to be_disallowed(:create_design, :destroy_design) } - end - context "when DesignManagement is not enabled" do before do enable_design_management(false) @@ -135,15 +133,13 @@ RSpec.describe DesignManagement::DesignPolicy do let_it_be(:project) { create(:project, :private) } let(:current_user) { guest } - it { is_expected.to be_allowed(*guest_design_abilities) } - it { is_expected.to be_disallowed(*developer_design_abilities) } + it_behaves_like "read-only design abilities" end context "for anonymous users in public projects" do let(:current_user) { nil } - it { is_expected.to be_allowed(*guest_design_abilities) } - it { is_expected.to be_disallowed(*developer_design_abilities) } + it_behaves_like "read-only design abilities" end context "when the issue is confidential" do @@ -164,20 +160,6 @@ RSpec.describe DesignManagement::DesignPolicy do end end - context "when the issue is locked" do - let_it_be(:issue) { create(:issue, :locked, project: project) } - let(:current_user) { owner } - - it_behaves_like "read-only design abilities" - end - - context "when the issue has moved" do - let_it_be(:issue) { create(:issue, project: project, moved_to: create(:issue)) } - let(:current_user) { owner } - - it_behaves_like "read-only design abilities" - end - context "when the project is archived" do let_it_be(:project) { create(:project, :public, :archived) } let_it_be(:issue) { create(:issue, project: project) } |