diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb
index 8bf81cd96..a00261a6e 100644
--- a/app/models/concerns/tags_substitution_concern.rb
+++ b/app/models/concerns/tags_substitution_concern.rb
@@ -60,9 +60,9 @@ module TagsSubstitutionConcern
libelle: 'lien attestation',
description: '',
lambda: -> (d) {
- links = [external_link(attestation_dossier_url(d))]
+ links = [external_link("Télécharger l'attestation", attestation_dossier_url(d))]
if d.justificatif_motivation.attached?
- links.push external_link_with_body("Télécharger l'attestation", url_for_justificatif_motivation(d))
+ links.push external_link("Télécharger le justificatif", url_for_justificatif_motivation(d))
end
links.join "
\n"
},
@@ -144,12 +144,8 @@ module TagsSubstitutionConcern
end
end
- def external_link(url)
- link_to(url, url, target: '_blank', rel: 'noopener')
- end
-
- def external_link_with_body(body, url)
- link_to(body, url, target: '_blank', rel: 'noopener')
+ def external_link(url, title = nil)
+ link_to(title || url, url, target: '_blank', rel: 'noopener')
end
def url_for_justificatif_motivation(dossier)
diff --git a/spec/models/concern/mail_template_concern_spec.rb b/spec/models/concern/mail_template_concern_spec.rb
index f6c2a903e..adb8e7bdd 100644
--- a/spec/models/concern/mail_template_concern_spec.rb
+++ b/spec/models/concern/mail_template_concern_spec.rb
@@ -78,7 +78,7 @@ describe MailTemplateConcern do
describe "in closed mail without justificatif" do
let(:mail) { create(:closed_mail, procedure: procedure) }
it { is_expected.to eq("http://localhost:3000/dossiers/#{dossier.id}/attestation") }
- it { is_expected.to_not include("Télécharger l'attestation") }
+ it { is_expected.to include("Télécharger l'attestation") }
end
describe "in closed mail with justificatif" do
@@ -90,6 +90,7 @@ describe MailTemplateConcern do
it { expect(dossier.justificatif_motivation).to be_attached }
it { is_expected.to start_with("http://localhost:3000/dossiers/#{dossier.id}/attestation
\n") }
it { is_expected.to include("Télécharger l'attestation") }
+ it { is_expected.to include("Télécharger le justificatif") }
end
describe "in refuse mail" do