diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-07 01:28:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-07 01:28:28 +0300 |
commit | e4a92d342784ccbb929e7d2b1faa42d6c2f591a3 (patch) | |
tree | 0e850cae1809a9224f5dcd773933777dbd4c17de /spec/models/user_spec.rb | |
parent | 89e372068b3909b0e8cfb03af4da176357a1abbc (diff) |
Add latest changes from gitlab-org/security/gitlab@15-7-stable-ee
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r-- | spec/models/user_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 4a66af4ddf1..4dbcc68af19 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -311,6 +311,34 @@ RSpec.describe User do end end end + + describe 'confirmation instructions for unconfirmed email' do + let(:unconfirmed_email) { 'first-unconfirmed-email@example.com' } + let(:another_unconfirmed_email) { 'another-unconfirmed-email@example.com' } + + context 'when email is changed to another before performing the job that sends confirmation instructions for previous email change request' do + it "mentions the recipient's email in the message body", :aggregate_failures do + same_user = User.find(user.id) + same_user.update!(email: unconfirmed_email) + + user.update!(email: another_unconfirmed_email) + + perform_enqueued_jobs + + confirmation_instructions_for_unconfirmed_email = ActionMailer::Base.deliveries.find do |message| + message.subject == 'Confirmation instructions' && message.to.include?(unconfirmed_email) + end + expect(confirmation_instructions_for_unconfirmed_email.html_part.body.encoded).to match same_user.unconfirmed_email + expect(confirmation_instructions_for_unconfirmed_email.text_part.body.encoded).to match same_user.unconfirmed_email + + confirmation_instructions_for_another_unconfirmed_email = ActionMailer::Base.deliveries.find do |message| + message.subject == 'Confirmation instructions' && message.to.include?(another_unconfirmed_email) + end + expect(confirmation_instructions_for_another_unconfirmed_email.html_part.body.encoded).to match user.unconfirmed_email + expect(confirmation_instructions_for_another_unconfirmed_email.text_part.body.encoded).to match user.unconfirmed_email + end + end + end end describe 'validations' do |