diff --git a/app/forms/register_user_email_form.rb b/app/forms/register_user_email_form.rb index 6aa1cb2046a..07afaf21bc2 100644 --- a/app/forms/register_user_email_form.rb +++ b/app/forms/register_user_email_form.rb @@ -170,7 +170,7 @@ def send_sign_up_confirmed_email ) else UserMailer.with(user: existing_user, email_address: email_address_record). - signup_with_your_email.deliver_now_or_later + signup_with_your_email(request_id: request_id).deliver_now_or_later end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 48790c362c1..6b742826e28 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -73,9 +73,9 @@ def email_confirmation_instructions(token, request_id:) end end - def signup_with_your_email + def signup_with_your_email(request_id:) with_user_locale(user) do - @root_url = root_url(locale: locale_url_param) + @root_url = root_url(locale: locale_url_param, request_id: request_id) mail(to: email_address.email, subject: t('mailer.email_reuse_notice.subject')) end end diff --git a/spec/mailers/previews/user_mailer_preview.rb b/spec/mailers/previews/user_mailer_preview.rb index 8acb83c15f6..64abf105d1a 100644 --- a/spec/mailers/previews/user_mailer_preview.rb +++ b/spec/mailers/previews/user_mailer_preview.rb @@ -8,7 +8,8 @@ def email_confirmation_instructions end def signup_with_your_email - UserMailer.with(user: user, email_address: email_address_record).signup_with_your_email + UserMailer.with(user: user, email_address: email_address_record). + signup_with_your_email(request_id: SecureRandom.uuid) end def reset_password_instructions diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index 4ec60f3f88a..61bad58336a 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -8,7 +8,11 @@ let(:is_enhanced_ipp) { false } describe '#validate_user_and_email_address' do - let(:mail) { UserMailer.with(user: user, email_address: email_address).signup_with_your_email } + let(:request_id) { '1234-abcd' } + let(:mail) do + UserMailer.with(user: user, email_address: email_address). + signup_with_your_email(request_id: request_id) + end context 'with user and email address match' do it 'does not raise an error' do @@ -210,8 +214,10 @@ end describe '#signup_with_your_email' do + let(:request_id) { '1234-abcd' } let(:mail) do - UserMailer.with(user: user, email_address: user.email_addresses.first).signup_with_your_email + UserMailer.with(user: user, email_address: user.email_addresses.first). + signup_with_your_email(request_id: request_id) end it_behaves_like 'a system email'