2017-05-02 15:37:06 +02:00
RSpec . describe AvisMailer , type : :mailer do
2017-06-07 18:18:24 +02:00
describe '.avis_invitation' do
2017-05-02 15:37:06 +02:00
let ( :avis ) { create ( :avis ) }
2017-06-07 18:18:24 +02:00
subject { described_class . avis_invitation ( avis ) }
2017-05-02 15:37:06 +02:00
it { expect ( subject . subject ) . to eq ( " Donnez votre avis sur le dossier nº #{ avis . dossier . id } ( #{ avis . dossier . procedure . libelle } ) " ) }
2018-12-04 11:06:04 +01:00
it { expect ( subject . body ) . to have_text ( " Vous avez été invité par \r \n #{ avis . claimant . email } \r \n à donner votre avis sur le dossier nº #{ avis . dossier . id } de la démarche : \r \n #{ avis . dossier . procedure . libelle } " ) }
2017-05-02 15:37:06 +02:00
it { expect ( subject . body ) . to include ( avis . introduction ) }
2019-08-06 11:02:54 +02:00
it { expect ( subject . body ) . to include ( instructeur_avis_url ( avis ) ) }
2018-08-08 13:19:23 +02:00
context 'when the recipient is not already registered' do
before do
2018-08-29 22:11:38 +02:00
avis . email = 'instructeur@email.com'
2019-08-06 11:02:54 +02:00
avis . instructeur = nil
2018-08-08 13:19:23 +02:00
end
2019-08-06 11:02:54 +02:00
it { expect ( subject . body ) . to include ( sign_up_instructeur_avis_url ( avis . id , avis . email ) ) }
2018-08-08 13:19:23 +02:00
end
2017-05-02 15:37:06 +02:00
end
end