Commit ad44af2f authored by James Lopez's avatar James Lopez

fixed specs

parent 7aaf3692
...@@ -511,7 +511,7 @@ module API ...@@ -511,7 +511,7 @@ module API
not_found!('Email') unless email not_found!('Email') unless email
email.destroy 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! user.update_secondary_emails!
end end
end end
......
...@@ -19,7 +19,7 @@ describe Emails::CreateService, services: true do ...@@ -19,7 +19,7 @@ describe Emails::CreateService, services: true do
end end
it 'does not create an email if the user has no permissions' do 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 end
it 'creates an email if we skip authorization' do it 'creates an email if we skip authorization' do
......
...@@ -12,12 +12,14 @@ describe Emails::DestroyService, services: true do ...@@ -12,12 +12,14 @@ describe Emails::DestroyService, services: true do
end end
it 'does not remove an email if the user has no permissions' do 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 end
it 'removes an email if we skip authorization' do it 'removes an email if we skip authorization' do
expect 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.to change { Email.count }.by(-1)
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