From 70608f824e4bdd197d179c70efc82effcefc0c6b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 20 May 2024 04:03:39 -0400 Subject: [PATCH] Add coverage for `AdminMailer#auto_close_registrations` (#30349) --- spec/mailers/admin_mailer_spec.rb | 18 ++++++++++++++++++ spec/mailers/previews/admin_mailer_preview.rb | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/spec/mailers/admin_mailer_spec.rb b/spec/mailers/admin_mailer_spec.rb index 88ad7aa02b..cd1ab3311c 100644 --- a/spec/mailers/admin_mailer_spec.rb +++ b/spec/mailers/admin_mailer_spec.rb @@ -125,4 +125,22 @@ RSpec.describe AdminMailer do .and(have_header('X-Priority', '1')) end end + + describe '.auto_close_registrations' do + let(:recipient) { Fabricate(:account, username: 'Bob') } + let(:mail) { described_class.with(recipient: recipient).auto_close_registrations } + + before do + recipient.user.update(locale: :en) + end + + it 'renders the email' do + expect(mail) + .to be_present + .and(deliver_to(recipient.user_email)) + .and(deliver_from('notifications@localhost')) + .and(have_subject('Registrations for cb6e6126.ngrok.io have been automatically switched to requiring approval')) + .and(have_body_text('have been automatically switched')) + end + end end diff --git a/spec/mailers/previews/admin_mailer_preview.rb b/spec/mailers/previews/admin_mailer_preview.rb index 942d40d568..b8fb387acd 100644 --- a/spec/mailers/previews/admin_mailer_preview.rb +++ b/spec/mailers/previews/admin_mailer_preview.rb @@ -32,4 +32,9 @@ class AdminMailerPreview < ActionMailer::Preview def new_critical_software_updates AdminMailer.with(recipient: Account.first).new_critical_software_updates end + + # Preview this email at http://localhost:3000/rails/mailers/admin_mailer/auto_close_registrations + def auto_close_registrations + AdminMailer.with(recipient: Account.first).auto_close_registrations + end end