diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/services/emails/create_service_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/services/emails/create_service_spec.rb')
-rw-r--r-- | spec/services/emails/create_service_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/services/emails/create_service_spec.rb b/spec/services/emails/create_service_spec.rb index 2fabf4ae66a..b13197f21b8 100644 --- a/spec/services/emails/create_service_spec.rb +++ b/spec/services/emails/create_service_spec.rb @@ -25,5 +25,34 @@ RSpec.describe Emails::CreateService do expect(user.emails).to include(Email.find_by(opts)) end + + it 'sends a notification to the user' do + expect_next_instance_of(NotificationService) do |notification_service| + expect(notification_service).to receive(:new_email_address_added) + end + + service.execute + end + + it 'does not send a notification when the email is not persisted' do + allow_next_instance_of(NotificationService) do |notification_service| + expect(notification_service).not_to receive(:new_email_address_added) + end + + service.execute(email: 'invalid@@example.com') + end + + it 'does not send a notification email when the email is the primary, because we are creating the user' do + allow_next_instance_of(NotificationService) do |notification_service| + expect(notification_service).not_to receive(:new_email_address_added) + end + + # This is here to ensure that the service is actually called. + allow_next_instance_of(described_class) do |create_service| + expect(create_service).to receive(:execute).and_call_original + end + + create(:user) + end end end |