summaryrefslogtreecommitdiff
path: root/spec/policies
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-13 06:08:10 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-13 06:08:10 +0000
commit6ede90f5dd63d4a1f5ba243b4ed5097bb1a0acab (patch)
tree6bb9e934cdd90d62e672a1d6c4a5a63995bfbb00 /spec/policies
parentb8e30b446d9cb91b94d2b55e5c81303c8f2d1b25 (diff)
downloadgitlab-ce-6ede90f5dd63d4a1f5ba243b4ed5097bb1a0acab.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/policies')
-rw-r--r--spec/policies/user_policy_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/policies/user_policy_spec.rb b/spec/policies/user_policy_spec.rb
index 9da9d2ce49b..0af58e96c5e 100644
--- a/spec/policies/user_policy_spec.rb
+++ b/spec/policies/user_policy_spec.rb
@@ -48,4 +48,36 @@ describe UserPolicy do
describe "updating a user" do
it_behaves_like 'changing a user', :update_user
end
+
+ describe "updating a user's name" do
+ context 'when the ability to update their name is not disabled for users' do
+ before do
+ stub_application_setting(updating_name_disabled_for_users: false)
+ end
+
+ it_behaves_like 'changing a user', :update_name
+ end
+
+ context 'when the ability to update their name is disabled for users' do
+ before do
+ stub_application_setting(updating_name_disabled_for_users: true)
+ end
+
+ context 'for a regular user' do
+ it { is_expected.not_to be_allowed(:update_name) }
+ end
+
+ context 'for a ghost user' do
+ let(:current_user) { create(:user, :ghost) }
+
+ it { is_expected.not_to be_allowed(:update_name) }
+ end
+
+ context 'for an admin user' do
+ let(:current_user) { create(:admin) }
+
+ it { is_expected.to be_allowed(:update_name) }
+ end
+ end
+ end
end