diff options
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/group_policy_spec.rb | 8 | ||||
-rw-r--r-- | spec/policies/namespaces/project_namespace_policy_spec.rb | 42 |
2 files changed, 12 insertions, 38 deletions
diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index c513baea517..57923142648 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -1229,4 +1229,12 @@ RSpec.describe GroupPolicy do it { is_expected.to be_disallowed(:admin_crm_contact) } it { is_expected.to be_disallowed(:admin_crm_organization) } end + + it_behaves_like 'checks timelog categories permissions' do + let(:group) { create(:group) } + let(:namespace) { group } + let(:users_container) { group } + + subject { described_class.new(current_user, group) } + end end diff --git a/spec/policies/namespaces/project_namespace_policy_spec.rb b/spec/policies/namespaces/project_namespace_policy_spec.rb index 5ceea9dfb9d..4519f44a6ad 100644 --- a/spec/policies/namespaces/project_namespace_policy_spec.rb +++ b/spec/policies/namespaces/project_namespace_policy_spec.rb @@ -3,45 +3,11 @@ require 'spec_helper' RSpec.describe Namespaces::ProjectNamespacePolicy do - let_it_be(:parent) { create(:namespace) } - let_it_be(:project) { create(:project, namespace: parent) } - let_it_be(:namespace) { project.project_namespace } - - let(:permissions) do - [:owner_access, :create_projects, :admin_namespace, :read_namespace, - :read_statistics, :transfer_projects, :admin_package, - :create_jira_connect_subscription] - end - subject { described_class.new(current_user, namespace) } - context 'with no user' do - let_it_be(:current_user) { nil } - - it { is_expected.to be_disallowed(*permissions) } - end - - context 'regular user' do - let_it_be(:current_user) { create(:user) } - - it { is_expected.to be_disallowed(*permissions) } - end - - context 'parent owner' do - let_it_be(:current_user) { parent.first_owner } - - it { is_expected.to be_disallowed(*permissions) } - end - - context 'admin' do - let_it_be(:current_user) { create(:admin) } - - context 'when admin mode is enabled', :enable_admin_mode do - it { is_expected.to be_disallowed(*permissions) } - end - - context 'when admin mode is disabled' do - it { is_expected.to be_disallowed(*permissions) } - end + it_behaves_like 'checks timelog categories permissions' do + let(:project) { create(:project) } + let(:namespace) { project.project_namespace } + let(:users_container) { project } end end |