#4103 - Ajout du tag 'lien document justificatif' (#4104)

Administrateur : ajout d'une balise `--lien document justificatif--`
This commit is contained in:
Pierre de La Morinerie 2019-07-17 12:03:00 +02:00 committed by GitHub
commit 9b68bb344e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 8 deletions

View file

@ -59,14 +59,20 @@ module TagsSubstitutionConcern
{
libelle: 'lien attestation',
description: '',
lambda: -> (d) {
links = [external_link(attestation_dossier_url(d))]
if d.justificatif_motivation.attached?
links.push external_link("Télécharger le justificatif", url_for_justificatif_motivation(d))
end
links.join "<br />\n"
},
lambda: -> (d) { external_link(attestation_dossier_url(d)) },
available_for_states: [Dossier.states.fetch(:accepte)]
},
{
libelle: 'lien document justificatif',
description: '',
lambda: -> (d) {
if d.justificatif_motivation.attached?
external_link(url_for_justificatif_motivation(d), "Télécharger le document justificatif")
else
return "[l'instructeur n'a pas joint de document supplémentaire]"
end
},
available_for_states: Dossier::TERMINE
}
]

View file

@ -89,7 +89,7 @@ describe MailTemplateConcern do
it { expect(dossier.justificatif_motivation).to be_attached }
it { is_expected.to include("<a target=\"_blank\" rel=\"noopener\" href=\"http://localhost:3000/dossiers/#{dossier.id}/attestation\">http://localhost:3000/dossiers/#{dossier.id}/attestation</a>") }
it { is_expected.to include("Télécharger le justificatif") }
it { is_expected.to_not include("Télécharger le justificatif") }
end
describe "in refuse mail" do
@ -104,6 +104,43 @@ describe MailTemplateConcern do
it { is_expected.to eq("--lien attestation--") }
end
end
shared_examples 'inserting the --lien document justificatif-- tag' do
let(:procedure) { create(:procedure) }
subject { mail.body_for_dossier(dossier) }
before do
mail.body = "--lien document justificatif--"
end
describe 'without justificatif' do
it { is_expected.to include("[l'instructeur n'a pas joint de document supplémentaire]") }
end
describe 'with justificatif' do
before do
dossier.justificatif_motivation.attach(justificatif)
end
it { expect(dossier.justificatif_motivation).to be_attached }
it { is_expected.to include("Télécharger le document justificatif") }
end
end
context 'in closed mail' do
let(:mail) { create(:closed_mail, procedure: procedure) }
it_behaves_like 'inserting the --lien document justificatif-- tag'
end
context 'in refused mail' do
let(:mail) { create(:refused_mail, procedure: procedure) }
it_behaves_like 'inserting the --lien document justificatif-- tag'
end
context 'in without continuation mail' do
let(:mail) { create(:without_continuation_mail, procedure: procedure) }
it_behaves_like 'inserting the --lien document justificatif-- tag'
end
end
describe '#replace_tags' do