cleanup the tag substitution concern & uniformization
This commit is contained in:
parent
653eff01f0
commit
0e26bda186
2 changed files with 6 additions and 9 deletions
|
@ -60,9 +60,9 @@ module TagsSubstitutionConcern
|
||||||
libelle: 'lien attestation',
|
libelle: 'lien attestation',
|
||||||
description: '',
|
description: '',
|
||||||
lambda: -> (d) {
|
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?
|
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
|
end
|
||||||
links.join "<br />\n"
|
links.join "<br />\n"
|
||||||
},
|
},
|
||||||
|
@ -144,12 +144,8 @@ module TagsSubstitutionConcern
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def external_link(url)
|
def external_link(url, title = nil)
|
||||||
link_to(url, url, target: '_blank', rel: 'noopener')
|
link_to(title || url, url, target: '_blank', rel: 'noopener')
|
||||||
end
|
|
||||||
|
|
||||||
def external_link_with_body(body, url)
|
|
||||||
link_to(body, url, target: '_blank', rel: 'noopener')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def url_for_justificatif_motivation(dossier)
|
def url_for_justificatif_motivation(dossier)
|
||||||
|
|
|
@ -78,7 +78,7 @@ describe MailTemplateConcern do
|
||||||
describe "in closed mail without justificatif" do
|
describe "in closed mail without justificatif" do
|
||||||
let(:mail) { create(:closed_mail, procedure: procedure) }
|
let(:mail) { create(:closed_mail, procedure: procedure) }
|
||||||
it { is_expected.to eq("<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 eq("<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_not include("Télécharger l'attestation") }
|
it { is_expected.to include("Télécharger l'attestation") }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "in closed mail with justificatif" do
|
describe "in closed mail with justificatif" do
|
||||||
|
@ -90,6 +90,7 @@ describe MailTemplateConcern do
|
||||||
it { expect(dossier.justificatif_motivation).to be_attached }
|
it { expect(dossier.justificatif_motivation).to be_attached }
|
||||||
it { is_expected.to start_with("<a target=\"_blank\" rel=\"noopener\" href=\"http://localhost:3000/dossiers/#{dossier.id}/attestation\">http://localhost:3000/dossiers/#{dossier.id}/attestation</a><br />\n") }
|
it { is_expected.to start_with("<a target=\"_blank\" rel=\"noopener\" href=\"http://localhost:3000/dossiers/#{dossier.id}/attestation\">http://localhost:3000/dossiers/#{dossier.id}/attestation</a><br />\n") }
|
||||||
it { is_expected.to include("Télécharger l'attestation") }
|
it { is_expected.to include("Télécharger l'attestation") }
|
||||||
|
it { is_expected.to include("Télécharger le justificatif") }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "in refuse mail" do
|
describe "in refuse mail" do
|
||||||
|
|
Loading…
Reference in a new issue