diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-23 12:09:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-23 12:09:51 +0300 |
commit | 66e4d1bf78b3ec2075135173b12767692ced242c (patch) | |
tree | 1ea67cbc46ee2c6b61e0872699a89f0fb600bef1 /spec/policies | |
parent | 1d659e434d7c966a8a0c27fb17dc36d80ae70180 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r-- | spec/policies/namespaces/project_namespace_policy_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/policies/namespaces/project_namespace_policy_spec.rb b/spec/policies/namespaces/project_namespace_policy_spec.rb new file mode 100644 index 00000000000..22f3ccec1f8 --- /dev/null +++ b/spec/policies/namespaces/project_namespace_policy_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe NamespacePolicy do + let_it_be(:parent) { create(:namespace) } + let_it_be(:namespace) { create(:project_namespace, parent: parent) } + + let(:permissions) do + [:owner_access, :create_projects, :admin_namespace, :read_namespace, + :read_statistics, :transfer_projects, :create_package_settings, + :read_package_settings, :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.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_allowed(*permissions) } + end + + context 'when admin mode is disabled' do + it { is_expected.to be_disallowed(*permissions) } + end + end +end |