2017-05-02 15:37:06 +02:00
require " rails_helper "
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-11-23 11:04:28 +01:00
it { expect ( subject . body ) . to have_text ( " Vous avez été invité par #{ avis . claimant . email } à donner votre avis sur le dossier nº #{ avis . dossier . id } de la démarche : #{ avis . dossier . procedure . libelle } " ) }
2017-05-02 15:37:06 +02:00
it { expect ( subject . body ) . to include ( avis . introduction ) }
2018-08-08 13:19:23 +02:00
it { expect ( subject . body ) . to include ( gestionnaire_avis_url ( avis ) ) }
context 'when the recipient is not already registered' do
before do
2018-08-29 22:11:38 +02:00
avis . email = 'instructeur@email.com'
2018-08-08 13:19:23 +02:00
avis . gestionnaire = nil
end
it { expect ( subject . body ) . to include ( sign_up_gestionnaire_avis_url ( avis . id , avis . email ) ) }
end
2017-05-02 15:37:06 +02:00
end
end