feat(user): always allow invitation mail

This commit is contained in:
simon lehericey 2024-05-29 12:24:05 +02:00
parent 5d259ec47b
commit 7c514e3585
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
6 changed files with 36 additions and 4 deletions

View file

@ -8,6 +8,8 @@ class AdministrateurMailer < ApplicationMailer
@expiration_date = @user.reset_password_sent_at + Devise.reset_password_within
@subject = "N'oubliez pas dactiver votre compte administrateur"
bypass_unverified_mail_protection!
mail(to: user.email,
subject: @subject,
reply_to: CONTACT_EMAIL)

View file

@ -8,6 +8,8 @@ class AdministrationMailer < ApplicationMailer
@author_name = "Équipe de #{APPLICATION_NAME}"
subject = "Activez votre compte administrateur"
bypass_unverified_mail_protection!
mail(to: user.email,
subject: subject,
reply_to: CONTACT_EMAIL)
@ -16,6 +18,8 @@ class AdministrationMailer < ApplicationMailer
def refuse_admin(admin_email)
subject = "Votre demande de compte a été refusée"
bypass_unverified_mail_protection!
mail(to: admin_email,
subject: subject,
reply_to: CONTACT_EMAIL)

View file

@ -41,6 +41,8 @@ class UserMailer < ApplicationMailer
configure_defaults_for_user(user)
bypass_unverified_mail_protection!
mail(to: user.email,
subject: subject,
reply_to: Current.contact_email)
@ -54,6 +56,8 @@ class UserMailer < ApplicationMailer
configure_defaults_for_user(user)
bypass_unverified_mail_protection!
mail(to: user.email,
subject: subject,
reply_to: Current.contact_email)

View file

@ -23,7 +23,10 @@ RSpec.describe AdministrateurMailer, type: :mailer do
subject { described_class.activate_before_expiration(user, token) }
context 'without SafeMailer configured' do
it { expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil) }
it do
expect(subject[BalancerDeliveryMethod::FORCE_DELIVERY_METHOD_HEADER]&.value).to eq(nil)
expect(subject['BYPASS_UNVERIFIED_MAIL_PROTECTION']).to be_present
end
end
context 'with SafeMailer configured' do

View file

@ -9,8 +9,11 @@ RSpec.describe AdministrationMailer, type: :mailer do
it { expect(subject.subject).not_to be_empty }
describe "when the user has not been activated" do
it { expect(subject.body).to include(admin_activate_path(token: token)) }
it { expect(subject.body).not_to include(edit_user_password_url(admin_user, reset_password_token: token)) }
it do
expect(subject.body).to include(admin_activate_path(token: token))
expect(subject.body).not_to include(edit_user_password_url(admin_user, reset_password_token: token))
expect(subject['BYPASS_UNVERIFIED_MAIL_PROTECTION']).to be_present
end
end
describe "when the user is already active" do
@ -25,6 +28,9 @@ RSpec.describe AdministrationMailer, type: :mailer do
subject { described_class.refuse_admin(mail) }
it { expect(subject.subject).not_to be_empty }
it do
expect(subject.subject).not_to be_empty
expect(subject['BYPASS_UNVERIFIED_MAIL_PROTECTION']).to be_present
end
end
end

View file

@ -168,4 +168,17 @@ RSpec.describe UserMailer, type: :mailer do
end
end
end
describe '.invite_instructeur' do
subject { described_class.invite_instructeur(user, "reset_token") }
it { expect(subject['BYPASS_UNVERIFIED_MAIL_PROTECTION']).to be_present }
end
describe '.invite_gestionnaire' do
let(:groupe_gestionnaire) { create(:groupe_gestionnaire) }
subject { described_class.invite_gestionnaire(user, "reset_token", groupe_gestionnaire) }
it { expect(subject['BYPASS_UNVERIFIED_MAIL_PROTECTION']).to be_present }
end
end