ajout du tag 'lien document justificatif'

This commit is contained in:
clemkeirua 2019-07-15 20:51:03 +02:00 committed by Pierre de La Morinerie
parent 5bf622694a
commit b8fa567c81
2 changed files with 69 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::SOUMIS
}
]

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,61 @@ describe MailTemplateConcern do
it { is_expected.to eq("--lien attestation--") }
end
end
describe '--lien document justificatif--' do
let(:procedure) { create(:procedure) }
subject { mail.body_for_dossier(dossier) }
before do
mail.body = "--lien document justificatif--"
end
describe "in closed mail" do
let(:mail) { create(:closed_mail, procedure: procedure) }
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
describe "in refused mail" do
let(:mail) { create(:refused_mail, procedure: procedure) }
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
describe "in without continuation mail" do
let(:mail) { create(:without_continuation_mail, procedure: procedure) }
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
end
end
describe '#replace_tags' do