[#1563] Add lien attestation link to closed mail template

This commit is contained in:
Frederic Merizen 2018-03-16 17:17:26 +01:00
parent abf938ff1b
commit 84c864ed11
2 changed files with 31 additions and 0 deletions

View file

@ -49,6 +49,12 @@ module TagsSubstitutionConcern
description: '',
lambda: -> (d) { external_link(users_dossier_recapitulatif_url(d)) },
available_for_states: Dossier::SOUMIS
},
{
libelle: 'lien attestation',
description: '',
lambda: -> (d) { external_link(dossier_attestation_url(d)) },
available_for_states: ['accepte']
}
]

View file

@ -61,6 +61,31 @@ describe MailTemplateConcern do
expect(received_mail.tags).to include(include({ libelle: 'date de passage en instruction' }))
end
end
describe '--lien attestation--' do
let(:attestation_template) { AttestationTemplate.new(activated: true) }
let(:procedure) { create(:procedure, attestation_template: attestation_template) }
subject { mail.body_for_dossier(dossier) }
before do
dossier.attestation = dossier.build_attestation
dossier.reload
mail.body = "--lien attestation--"
end
describe "in closed mail" do
let(:mail) { create(:closed_mail, procedure: procedure) }
it { is_expected.to eq("<a target=\"_blank\" href=\"http://localhost:3000/dossiers/#{dossier.id}/attestation\">http://localhost:3000/dossiers/#{dossier.id}/attestation</a>") }
end
describe "in refuse mail" do
let(:mail) { create(:refused_mail, procedure: procedure) }
it { is_expected.to eq("--lien attestation--") }
end
end
end
describe '#replace_tags' do