blob: 6db050148cbcb5ad16f3822f876e106edb34ae53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
require 'spec_helper'
describe Emails::DestroyService, services: true do
let!(:user) { create(:user) }
let!(:email) { create(:email, user: user) }
subject(:service) { described_class.new(user, user, email: email.email) }
describe '#execute' do
it 'removes an email' do
expect { service.execute }.to change { user.emails.count }.by(-1)
end
it 'does not remove an email if the user has no permissions' do
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, email: email.email).execute(skip_authorization: true)
end.to change { Email.count }.by(-1)
end
end
end
|