Skip to content

Commit

Permalink
LG-14204: Add Request id to sign up email (#11286)
Browse files Browse the repository at this point in the history
* changelog: Bug Fixes, Sign up, Add request id

* user mailer spec fixes
  • Loading branch information
mdiarra3 authored Sep 27, 2024
1 parent de3f80f commit b423e5a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/forms/register_user_email_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion spec/mailers/previews/user_mailer_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions spec/mailers/user_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit b423e5a

Please sign in to comment.