diff options
author | James Lopez <james@jameslopez.es> | 2017-06-13 17:24:36 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-06-23 12:41:41 +0300 |
commit | cf6286313d2e5296e1009c3bcae7da50d7e438a4 (patch) | |
tree | 655d0564b52206f92ee109c00ac5fe9a8311f742 /spec/services/users | |
parent | 11044ab1a02ffc681c46f1edb083dea163954b99 (diff) |
added bang option to spec
Diffstat (limited to 'spec/services/users')
-rw-r--r-- | spec/services/users/update_service_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/services/users/update_service_spec.rb b/spec/services/users/update_service_spec.rb index 87a3957bc3b..fd32a4f0f33 100644 --- a/spec/services/users/update_service_spec.rb +++ b/spec/services/users/update_service_spec.rb @@ -7,6 +7,7 @@ describe Users::UpdateService, services: true do describe '#execute' do it 'updates the name' do result = update_user(user, user, name: 'New Name') + expect(result).to eq({ status: :success }) expect(user.name).to eq('New Name') end @@ -14,6 +15,7 @@ describe Users::UpdateService, services: true do context 'when updated by an admin' do it 'updates the name' do result = update_user(admin, user, name: 'New Name') + expect(result).to eq({ status: :success }) expect(user.name).to eq('New Name') end @@ -29,4 +31,32 @@ describe Users::UpdateService, services: true do described_class.new(current_user, user, opts).execute end end + + describe '#execute!' do + it 'updates the name' do + result = update_user(user, user, name: 'New Name') + + expect(result).to be true + expect(user.name).to eq('New Name') + end + + context 'when updated by an admin' do + it 'updates the name' do + result = update_user(admin, user, name: 'New Name') + + expect(result).to be true + expect(user.name).to eq('New Name') + end + end + + it 'returns an error result when record cannot be updated' do + expect do + update_user(user, create(:user), { name: 'New Name' }) + end.to raise_error Gitlab::Access::AccessDeniedError + end + + def update_user(current_user, user, opts) + described_class.new(current_user, user, opts).execute! + end + end end |