Misc spec/refactor to user mailer and user mailer spec (#27486)
This commit is contained in:
parent
37929b9707
commit
1f5187e2e2
4 changed files with 65 additions and 51 deletions
|
@ -5,7 +5,7 @@ require 'rails_helper'
|
|||
describe UserMailer do
|
||||
let(:receiver) { Fabricate(:user) }
|
||||
|
||||
describe 'confirmation_instructions' do
|
||||
describe '#confirmation_instructions' do
|
||||
let(:mail) { described_class.confirmation_instructions(receiver, 'spec') }
|
||||
|
||||
it 'renders confirmation instructions' do
|
||||
|
@ -20,7 +20,7 @@ describe UserMailer do
|
|||
instance: Rails.configuration.x.local_domain
|
||||
end
|
||||
|
||||
describe 'reconfirmation_instructions' do
|
||||
describe '#reconfirmation_instructions' do
|
||||
let(:mail) { described_class.confirmation_instructions(receiver, 'spec') }
|
||||
|
||||
it 'renders reconfirmation instructions' do
|
||||
|
@ -34,7 +34,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'reset_password_instructions' do
|
||||
describe '#reset_password_instructions' do
|
||||
let(:mail) { described_class.reset_password_instructions(receiver, 'spec') }
|
||||
|
||||
it 'renders reset password instructions' do
|
||||
|
@ -47,7 +47,7 @@ describe UserMailer do
|
|||
'devise.mailer.reset_password_instructions.subject'
|
||||
end
|
||||
|
||||
describe 'password_change' do
|
||||
describe '#password_change' do
|
||||
let(:mail) { described_class.password_change(receiver) }
|
||||
|
||||
it 'renders password change notification' do
|
||||
|
@ -59,7 +59,7 @@ describe UserMailer do
|
|||
'devise.mailer.password_change.subject'
|
||||
end
|
||||
|
||||
describe 'email_changed' do
|
||||
describe '#email_changed' do
|
||||
let(:mail) { described_class.email_changed(receiver) }
|
||||
|
||||
it 'renders email change notification' do
|
||||
|
@ -71,7 +71,7 @@ describe UserMailer do
|
|||
'devise.mailer.email_changed.subject'
|
||||
end
|
||||
|
||||
describe 'warning' do
|
||||
describe '#warning' do
|
||||
let(:strike) { Fabricate(:account_warning, target_account: receiver.account, text: 'dont worry its just the testsuite', action: 'suspend') }
|
||||
let(:mail) { described_class.warning(receiver, strike) }
|
||||
|
||||
|
@ -82,7 +82,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'webauthn_credential_deleted' do
|
||||
describe '#webauthn_credential_deleted' do
|
||||
let(:credential) { Fabricate(:webauthn_credential, user_id: receiver.id) }
|
||||
let(:mail) { described_class.webauthn_credential_deleted(receiver, credential) }
|
||||
|
||||
|
@ -95,7 +95,7 @@ describe UserMailer do
|
|||
'devise.mailer.webauthn_credential.deleted.subject'
|
||||
end
|
||||
|
||||
describe 'suspicious_sign_in' do
|
||||
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 }
|
||||
|
@ -110,7 +110,7 @@ describe UserMailer do
|
|||
'user_mailer.suspicious_sign_in.subject'
|
||||
end
|
||||
|
||||
describe 'appeal_approved' do
|
||||
describe '#appeal_approved' do
|
||||
let(:appeal) { Fabricate(:appeal, account: receiver.account, approved_at: Time.now.utc) }
|
||||
let(:mail) { described_class.appeal_approved(receiver, appeal) }
|
||||
|
||||
|
@ -120,7 +120,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'appeal_rejected' do
|
||||
describe '#appeal_rejected' do
|
||||
let(:appeal) { Fabricate(:appeal, account: receiver.account, rejected_at: Time.now.utc) }
|
||||
let(:mail) { described_class.appeal_rejected(receiver, appeal) }
|
||||
|
||||
|
@ -130,7 +130,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'two_factor_enabled' do
|
||||
describe '#two_factor_enabled' do
|
||||
let(:mail) { described_class.two_factor_enabled(receiver) }
|
||||
|
||||
it 'renders two_factor_enabled mail' do
|
||||
|
@ -139,7 +139,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'two_factor_disabled' do
|
||||
describe '#two_factor_disabled' do
|
||||
let(:mail) { described_class.two_factor_disabled(receiver) }
|
||||
|
||||
it 'renders two_factor_disabled mail' do
|
||||
|
@ -148,7 +148,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'webauthn_enabled' do
|
||||
describe '#webauthn_enabled' do
|
||||
let(:mail) { described_class.webauthn_enabled(receiver) }
|
||||
|
||||
it 'renders webauthn_enabled mail' do
|
||||
|
@ -157,7 +157,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'webauthn_disabled' do
|
||||
describe '#webauthn_disabled' do
|
||||
let(:mail) { described_class.webauthn_disabled(receiver) }
|
||||
|
||||
it 'renders webauthn_disabled mail' do
|
||||
|
@ -166,7 +166,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'two_factor_recovery_codes_changed' do
|
||||
describe '#two_factor_recovery_codes_changed' do
|
||||
let(:mail) { described_class.two_factor_recovery_codes_changed(receiver) }
|
||||
|
||||
it 'renders two_factor_recovery_codes_changed mail' do
|
||||
|
@ -175,7 +175,7 @@ describe UserMailer do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'webauthn_credential_added' do
|
||||
describe '#webauthn_credential_added' do
|
||||
let(:credential) { Fabricate.build(:webauthn_credential) }
|
||||
let(:mail) { described_class.webauthn_credential_added(receiver, credential) }
|
||||
|
||||
|
@ -184,4 +184,23 @@ describe UserMailer do
|
|||
expect(mail.body.encoded).to include I18n.t('devise.mailer.webauthn_credential.added.explanation')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#welcome' do
|
||||
let(:mail) { described_class.welcome(receiver) }
|
||||
|
||||
it 'renders welcome mail' do
|
||||
expect(mail.subject).to eq I18n.t('user_mailer.welcome.subject')
|
||||
expect(mail.body.encoded).to include I18n.t('user_mailer.welcome.explanation')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#backup_ready' do
|
||||
let(:backup) { Fabricate(:backup) }
|
||||
let(:mail) { described_class.backup_ready(receiver, backup) }
|
||||
|
||||
it 'renders backup_ready mail' do
|
||||
expect(mail.subject).to eq I18n.t('user_mailer.backup_ready.subject')
|
||||
expect(mail.body.encoded).to include I18n.t('user_mailer.backup_ready.explanation')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue