diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 14:22:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 14:22:11 +0000 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/policies/group_policy_spec.rb | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) | |
download | gitlab-ce-0c872e02b2c822e3397515ec324051ff540f0cd5.tar.gz |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/policies/group_policy_spec.rb')
-rw-r--r-- | spec/policies/group_policy_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index 60acacac814..65abb43b6c4 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' RSpec.describe GroupPolicy do + include AdminModeHelper include_context 'GroupPolicy context' context 'public group with no user' do @@ -1190,12 +1191,28 @@ RSpec.describe GroupPolicy do context 'when admin mode is enabled', :enable_admin_mode do it { is_expected.to be_allowed(:register_group_runners) } + context 'with specific group runner registration disabled' do + before do + group.runner_registration_enabled = false + end + + it { is_expected.to be_allowed(:register_group_runners) } + end + context 'with group runner registration disabled' do before do stub_application_setting(valid_runner_registrars: ['project']) end it { is_expected.to be_allowed(:register_group_runners) } + + context 'with specific group runner registration disabled' do + before do + group.runner_registration_enabled = false + end + + it { is_expected.to be_allowed(:register_group_runners) } + end end end @@ -1216,6 +1233,14 @@ RSpec.describe GroupPolicy do it { is_expected.to be_disallowed(:register_group_runners) } end + + context 'with specific group runner registration disabled' do + before do + group.runner_registration_enabled = false + end + + it { is_expected.to be_disallowed(:register_group_runners) } + end end context 'with maintainer' do @@ -1344,4 +1369,32 @@ RSpec.describe GroupPolicy do subject { described_class.new(current_user, group) } end + + describe 'read_usage_quotas policy' do + context 'reading usage quotas' do + using RSpec::Parameterized::TableSyntax + + let(:policy) { :read_usage_quotas } + + where(:role, :admin_mode, :allowed) do + :owner | nil | true + :admin | true | true + :admin | false | false + :maintainer | nil | false + :developer | nil | false + :reporter | nil | false + :guest | nil | false + end + + with_them do + let(:current_user) { public_send(role) } + + before do + enable_admin_mode!(current_user) if admin_mode + end + + it { is_expected.to(allowed ? be_allowed(policy) : be_disallowed(policy)) } + end + end + end end |