From 164ac94bbd2eadc02ab54322a6fe12ed48ae8041 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 5 Sep 2023 12:11:04 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/policies/organizations/organization_policy_spec.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'spec/policies') diff --git a/spec/policies/organizations/organization_policy_spec.rb b/spec/policies/organizations/organization_policy_spec.rb index e51362227c9..3fcfa63b1b2 100644 --- a/spec/policies/organizations/organization_policy_spec.rb +++ b/spec/policies/organizations/organization_policy_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe Organizations::OrganizationPolicy, feature_category: :cell do let_it_be(:organization) { create(:organization) } + let_it_be(:current_user) { create :user } subject(:policy) { described_class.new(current_user, organization) } @@ -19,6 +20,7 @@ RSpec.describe Organizations::OrganizationPolicy, feature_category: :cell do 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) } + it { is_expected.to be_allowed(:read_organization_user) } end context 'when admin mode is disabled' do @@ -27,13 +29,19 @@ RSpec.describe Organizations::OrganizationPolicy, feature_category: :cell do end end - context 'when the user is an organization user' do - let_it_be(:current_user) { create :user } - + context 'when the user is part of the organization' do before do create :organization_user, organization: organization, user: current_user end + it { is_expected.to be_allowed(:read_organization_user) } + it { is_expected.to be_allowed(:read_organization) } + end + + context 'when the user is not part of the organization' do + it { is_expected.to be_disallowed(:read_organization_user) } + # All organizations are currently public, and hence they are allowed to be read + # even if the user is not a part of the organization. it { is_expected.to be_allowed(:read_organization) } end end -- cgit v1.2.3