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',
|
||||
description: '',
|
||||
lambda: -> (d) { users_dossier_recapitulatif_link(d) },
|
||||
lambda: -> (d) { external_link(users_dossier_recapitulatif_url(d)) },
|
||||
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
|
||||
|
||||
def users_dossier_recapitulatif_link(dossier)
|
||||
url = users_dossier_recapitulatif_url(dossier)
|
||||
def external_link(url)
|
||||
link_to(url, url, target: '_blank')
|
||||
end
|
||||
|
||||
|
|
|
@ -61,6 +61,31 @@ describe MailTemplateConcern do
|
|||
expect(received_mail.tags).to include(include({ libelle: 'date de passage en instruction' }))
|
||||
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
|
||||
|
||||
describe '#replace_tags' do
|
||||
|
|
Loading…
Reference in a new issue