summaryrefslogtreecommitdiff
path: root/spec/models/user_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/user_spec.rb')
-rw-r--r--spec/models/user_spec.rb28
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