summaryrefslogtreecommitdiff
path: root/spec/services/users
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/services/users
parentb8e30b446d9cb91b94d2b55e5c81303c8f2d1b25 (diff)
downloadgitlab-ce-6ede90f5dd63d4a1f5ba243b4ed5097bb1a0acab.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/users')
-rw-r--r--spec/services/users/update_service_spec.rb43
1 files changed, 38 insertions, 5 deletions
diff --git a/spec/services/users/update_service_spec.rb b/spec/services/users/update_service_spec.rb
index 9384287f98a..f3c15011213 100644
--- a/spec/services/users/update_service_spec.rb
+++ b/spec/services/users/update_service_spec.rb
@@ -6,11 +6,44 @@ describe Users::UpdateService do
let(:user) { create(:user) }
describe '#execute' do
- it 'updates the name' do
- result = update_user(user, name: 'New Name')
-
- expect(result).to eq(status: :success)
- expect(user.name).to eq('New Name')
+ context 'updating 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 'updates the name' do
+ result = update_user(user, name: 'New Name')
+
+ expect(result).to eq(status: :success)
+ expect(user.name).to eq('New Name')
+ end
+ 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 'executing as a regular user' do
+ it 'does not update the name' do
+ result = update_user(user, name: 'New Name')
+
+ expect(result).to eq(status: :success)
+ expect(user.name).not_to eq('New Name')
+ end
+ end
+
+ context 'executing as an admin user' do
+ it 'updates the name' do
+ admin = create(:admin)
+ result = described_class.new(admin, { user: user, name: 'New Name' }).execute
+
+ expect(result).to eq(status: :success)
+ expect(user.name).to eq('New Name')
+ end
+ end
+ end
end
it 'updates time preferences' do