Merge pull request #1659 from betagouv/frederic/fix_1563/add_lien_attestation_tag
#1563 : add lien attestation tag
This commit is contained in:
commit
c94cc53985
2 changed files with 33 additions and 3 deletions
|
@ -47,8 +47,14 @@ module TagsSubstitutionConcern
|
||||||
{
|
{
|
||||||
libelle: 'lien dossier',
|
libelle: 'lien dossier',
|
||||||
description: '',
|
description: '',
|
||||||
lambda: -> (d) { users_dossier_recapitulatif_link(d) },
|
lambda: -> (d) { external_link(users_dossier_recapitulatif_url(d)) },
|
||||||
available_for_states: Dossier::SOUMIS
|
available_for_states: Dossier::SOUMIS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
libelle: 'lien attestation',
|
||||||
|
description: '',
|
||||||
|
lambda: -> (d) { external_link(dossier_attestation_url(d)) },
|
||||||
|
available_for_states: ['accepte']
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -126,8 +132,7 @@ module TagsSubstitutionConcern
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def users_dossier_recapitulatif_link(dossier)
|
def external_link(url)
|
||||||
url = users_dossier_recapitulatif_url(dossier)
|
|
||||||
link_to(url, url, target: '_blank')
|
link_to(url, url, target: '_blank')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,31 @@ describe MailTemplateConcern do
|
||||||
expect(received_mail.tags).to include(include({ libelle: 'date de passage en instruction' }))
|
expect(received_mail.tags).to include(include({ libelle: 'date de passage en instruction' }))
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
describe '#replace_tags' do
|
describe '#replace_tags' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue