diff options
Diffstat (limited to 'spec/policies/organizations/organization_policy_spec.rb')
-rw-r--r-- | spec/policies/organizations/organization_policy_spec.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/policies/organizations/organization_policy_spec.rb b/spec/policies/organizations/organization_policy_spec.rb index 52d5a41aa7f..e51362227c9 100644 --- a/spec/policies/organizations/organization_policy_spec.rb +++ b/spec/policies/organizations/organization_policy_spec.rb @@ -7,21 +7,33 @@ RSpec.describe Organizations::OrganizationPolicy, feature_category: :cell do subject(:policy) { described_class.new(current_user, organization) } + context 'when the user is anonymous' do + let_it_be(:current_user) { nil } + + it { is_expected.to be_allowed(:read_organization) } + end + context 'when the user is an admin' do let_it_be(:current_user) { create(:user, :admin) } context 'when admin mode is enabled', :enable_admin_mode do it { is_expected.to be_allowed(:admin_organization) } + it { is_expected.to be_allowed(:read_organization) } end context 'when admin mode is disabled' do it { is_expected.to be_disallowed(:admin_organization) } + it { is_expected.to be_allowed(:read_organization) } end end - context 'when the user is not an admin' do - let_it_be(:current_user) { create(:user) } + context 'when the user is an organization user' do + let_it_be(:current_user) { create :user } + + before do + create :organization_user, organization: organization, user: current_user + end - it { is_expected.to be_disallowed(:admin_organization) } + it { is_expected.to be_allowed(:read_organization) } end end |