diff --git a/app/controllers/users/email_confirmations_controller.rb b/app/controllers/users/email_confirmations_controller.rb index 25a1e0c6b8c..503ac65601f 100644 --- a/app/controllers/users/email_confirmations_controller.rb +++ b/app/controllers/users/email_confirmations_controller.rb @@ -38,7 +38,9 @@ def process_successful_confirmation(email_address) def confirm_and_notify_user(email_address) email_address.update!(confirmed_at: Time.zone.now) - UserMailer.email_added(email_address.email).deliver_later + email_address.user.confirmed_email_addresses.each do |confirmed_email_address| + UserMailer.email_added(confirmed_email_address.email).deliver_later + end end def process_unsuccessful_confirmation diff --git a/spec/features/multiple_emails/add_email_spec.rb b/spec/features/multiple_emails/add_email_spec.rb index fcbb6393ac4..eb2fb971241 100644 --- a/spec/features/multiple_emails/add_email_spec.rb +++ b/spec/features/multiple_emails/add_email_spec.rb @@ -25,6 +25,7 @@ end it 'allows the user to add an email and confirm with an active session' do + allow(UserMailer).to receive(:email_added).and_call_original user = create(:user, :signed_up) sign_in_user_and_add_email(user) @@ -36,9 +37,11 @@ expect(page).to have_current_path(account_path) expect(page).to have_content(t('devise.confirmations.confirmed')) expect(page).to_not have_content email + t('email_addresses.unconfirmed') + expect(UserMailer).to have_received(:email_added).twice end it 'allows the user to add an email and confirm without an active session' do + allow(UserMailer).to receive(:email_added).and_call_original user = create(:user, :signed_up) sign_in_user_and_add_email(user) @@ -47,6 +50,7 @@ click_on_link_in_confirmation_email expect(page).to have_current_path(root_path) expect(page).to have_content(t('devise.confirmations.confirmed_but_sign_in')) + expect(UserMailer).to have_received(:email_added).twice end it 'notifies user they are already confirmed without an active session' do