Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 03:07:23 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 03:07:23 +0300
commit196f676f0e538e12501bc0ade8dd064c509230ba (patch)
tree024b06a803422eccad6a756ecf5d2357ed7ef0ba /spec/policies
parent97db9c4644d04ca42b65240f218f803529ad5cf2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/user_policy_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/policies/user_policy_spec.rb b/spec/policies/user_policy_spec.rb
index d02a94b810e..94b7e295167 100644
--- a/spec/policies/user_policy_spec.rb
+++ b/spec/policies/user_policy_spec.rb
@@ -246,4 +246,30 @@ RSpec.describe UserPolicy do
end
end
end
+
+ describe ':read_user_email_address' do
+ context 'when user is admin' do
+ let(:current_user) { admin }
+
+ context 'when admin mode is enabled', :enable_admin_mode do
+ it { is_expected.to be_allowed(:read_user_email_address) }
+ end
+
+ context 'when admin mode is disabled' do
+ it { is_expected.not_to be_allowed(:read_user_email_address) }
+ end
+ end
+
+ context 'when user is not an admin' do
+ context 'requesting their own' do
+ subject { described_class.new(current_user, current_user) }
+
+ it { is_expected.to be_allowed(:read_user_email_address) }
+ end
+
+ context "requesting a different user's" do
+ it { is_expected.not_to be_allowed(:read_user_email_address) }
+ end
+ end
+ end
end