fixed specs

This commit is contained in:
James Lopez 2017-06-16 15:14:46 +02:00
parent 7aaf3692b3
commit ad44af2faa
3 changed files with 6 additions and 4 deletions

View File

@ -511,7 +511,7 @@ module API
not_found!('Email') unless email
email.destroy
::Users::UpdateService.new(current_user, user).execute do |user|
::Users::UpdateService.new(current_user, current_user).execute do |user|
user.update_secondary_emails!
end
end

View File

@ -19,7 +19,7 @@ describe Emails::CreateService, services: true do
end
it 'does not create an email if the user has no permissions' do
expect { described_class.new(create(:user), user, opts).execute }.not_to change { Email.count }
expect { described_class.new(create(:user), user, opts).execute }.to raise_error(Gitlab::Access::AccessDeniedError)
end
it 'creates an email if we skip authorization' do

View File

@ -12,12 +12,14 @@ describe Emails::DestroyService, services: true do
end
it 'does not remove an email if the user has no permissions' do
expect { described_class.new(create(:user), user, opts).execute }.not_to change { Email.count }
expect do
described_class.new(create(:user), user, email: email.email).execute
end.to raise_error(Gitlab::Access::AccessDeniedError)
end
it 'removes an email if we skip authorization' do
expect do
described_class.new(create(:user), user, opts).execute(skip_authorization: true)
described_class.new(create(:user), user, email: email.email).execute(skip_authorization: true)
end.to change { Email.count }.by(-1)
end
end