Skip to content

Commit

Permalink
Utiliser from plutôt que reply-to dans les emails de file d’attente (#…
Browse files Browse the repository at this point in the history
…4898)

* Utiliser from plutôt que reply-to dans les emails de file d’attente

* fix specs
  • Loading branch information
adipasquale authored Dec 16, 2024
1 parent 4c59ac6 commit eafdda6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/mailers/users/file_attente_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Users::FileAttenteMailer < ApplicationMailer
@token = params[:token]
end

default to: -> { @user.email }, reply_to: -> { TransferEmailReplyJob.reply_address_for_rdv(@rdv) }
default to: -> { @user.email }

def new_creneau_available
subject = t("users.file_attente_mailer.new_creneau_available.title")
Expand All @@ -22,4 +22,8 @@ def save_receipt(subject)
def domain
@rdv.domain
end

def default_from
TransferEmailReplyJob.reply_address_for_rdv(@rdv)
end
end
15 changes: 15 additions & 0 deletions spec/mailers/users/file_attente_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
RSpec.describe Users::FileAttenteMailer, type: :mailer do
describe "#new_creneau_available" do
let(:rdv) { create(:rdv) }
let(:user) { rdv.users.first }
let(:mail) { described_class.with(rdv:, user:).new_creneau_available }

specify do
expect(mail[:from].to_s).to match(/"RDV Solidarités" <rdv\+[a-z0-9\-]+@reply\.rdv-solidarites-test\.localhost>/)
expect(mail.to).to eq([user.email])
expect(mail.reply_to).to be_nil
expect(mail.subject).to eq("Un créneau vient de se liberer !")
expect(mail.body.raw_source).to match(/Des créneaux pour votre RDV/) # for some reason, mail.html_part is nil
end
end
end

0 comments on commit eafdda6

Please sign in to comment.