Merge pull request #1659 from betagouv/frederic/fix_1563/add_lien_attestation_tag

#1563 : add lien attestation tag
This commit is contained in:
Frederic Merizen 2018-04-04 10:43:14 +02:00 committed by GitHub
commit c94cc53985
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View file

@ -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

View file

@ -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