Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/controllers/users/email_confirmations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/features/multiple_emails/add_email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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
Expand Down