diff options
Diffstat (limited to 'spec/services/emails/destroy_service_spec.rb')
-rw-r--r-- | spec/services/emails/destroy_service_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/services/emails/destroy_service_spec.rb b/spec/services/emails/destroy_service_spec.rb index f8407be41e7..7dcf367016e 100644 --- a/spec/services/emails/destroy_service_spec.rb +++ b/spec/services/emails/destroy_service_spec.rb @@ -15,5 +15,15 @@ RSpec.describe Emails::DestroyService do expect(user.emails).not_to include(email) expect(response).to be true end + + context 'when it corresponds to the user primary email' do + let(:email) { user.emails.find_by!(email: user.email) } + + it 'does not remove the email and raises an exception' do + expect { service.execute(email) }.to raise_error(StandardError, 'Cannot delete primary email') + + expect(user.emails).to include(email) + end + end end end |