1
0
Fork 0
forked from fedi/mastodon

User mailer spec coverage improvements (#23905)

This commit is contained in:
Matt Jankowski 2023-03-04 11:16:11 -05:00 committed by GitHub
parent 42ddc45133
commit 7f4412eeeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 1 deletions

View file

@ -17,7 +17,7 @@
%tbody
%tr
%td
= image_tag full_pack_url('media/images/mailer/icon_warning.png'), alt: ''
= image_tag full_pack_url('media/images/mailer/icon_flag.png'), alt: ''
%h1= t 'user_mailer.appeal_rejected.title'

View file

@ -94,4 +94,52 @@ describe UserMailer, type: :mailer do
expect(mail.body.encoded).to include strike.text
end
end
describe 'webauthn_credential_deleted' do
let(:credential) { Fabricate(:webauthn_credential, user_id: receiver.id) }
let(:mail) { UserMailer.webauthn_credential_deleted(receiver, credential) }
it 'renders webauthn credential deleted notification' do
receiver.update!(locale: nil)
expect(mail.body.encoded).to include I18n.t('devise.mailer.webauthn_credential.deleted.title')
end
include_examples 'localized subject',
'devise.mailer.webauthn_credential.deleted.subject'
end
describe 'suspicious_sign_in' do
let(:ip) { '192.168.0.1' }
let(:agent) { 'NCSA_Mosaic/2.0 (Windows 3.1)' }
let(:timestamp) { Time.now.utc }
let(:mail) { UserMailer.suspicious_sign_in(receiver, ip, agent, timestamp) }
it 'renders suspicious sign in notification' do
receiver.update!(locale: nil)
expect(mail.body.encoded).to include I18n.t('user_mailer.suspicious_sign_in.explanation')
end
include_examples 'localized subject',
'user_mailer.suspicious_sign_in.subject'
end
describe 'appeal_approved' do
let(:appeal) { Fabricate(:appeal, account: receiver.account, approved_at: Time.now.utc) }
let(:mail) { UserMailer.appeal_approved(receiver, appeal) }
it 'renders appeal_approved notification' do
expect(mail.subject).to eq I18n.t('user_mailer.appeal_approved.subject', date: I18n.l(appeal.created_at))
expect(mail.body.encoded).to include I18n.t('user_mailer.appeal_approved.title')
end
end
describe 'appeal_rejected' do
let(:appeal) { Fabricate(:appeal, account: receiver.account, rejected_at: Time.now.utc) }
let(:mail) { UserMailer.appeal_rejected(receiver, appeal) }
it 'renders appeal_rejected notification' do
expect(mail.subject).to eq I18n.t('user_mailer.appeal_rejected.subject', date: I18n.l(appeal.created_at))
expect(mail.body.encoded).to include I18n.t('user_mailer.appeal_rejected.title')
end
end
end