Commit 11044ab1 authored by James Lopez's avatar James Lopez

fix spec

parent 5f0e7873
...@@ -3,7 +3,6 @@ require 'spec_helper' ...@@ -3,7 +3,6 @@ require 'spec_helper'
describe Users::UpdateService, services: true do describe Users::UpdateService, services: true do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:user) { create(:empty_user, creator_id: user.id, namespace: user.namespace) }
describe '#execute' do describe '#execute' do
it 'updates the name' do it 'updates the name' do
...@@ -14,20 +13,20 @@ describe Users::UpdateService, services: true do ...@@ -14,20 +13,20 @@ describe Users::UpdateService, services: true do
context 'when updated by an admin' do context 'when updated by an admin' do
it 'updates the name' do it 'updates the name' do
result = update_user(user, admin, name: 'New Name') result = update_user(admin, user, name: 'New Name')
expect(result).to eq({ status: :success }) expect(result).to eq({ status: :success })
expect(user.name).to eq('New Name') expect(user.name).to eq('New Name')
end end
end end
it 'returns an error result when record cannot be updated' do it 'returns an error result when record cannot be updated' do
result = update_user(user, create(:user), { name: 'New Name' }) expect do
update_user(user, create(:user), { name: 'New Name' })
expect(result).to eq({ status: :error, message: 'User could not be updated' }) end.to raise_error Gitlab::Access::AccessDeniedError
end end
def update_user(current_user, user, opts) def update_user(current_user, user, opts)
described_class.new(user, user, opts).execute described_class.new(current_user, user, opts).execute
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment