dossier: add link to attestation when accepted

This commit is contained in:
Pierre de La Morinerie 2018-09-17 14:45:40 +02:00
parent fd7f07a244
commit 27727eabf3
3 changed files with 17 additions and 0 deletions

View file

@ -38,6 +38,9 @@
%h3 Motif de lacceptation
%blockquote= dossier.motivation
- if dossier.attestation.present?
= link_to 'Télécharger lattestation', attestation_dossier_path(dossier), target: '_blank', class: 'button primary'
- elsif dossier.refuse?
.refuse
%p

View file

@ -136,5 +136,14 @@ FactoryBot.define do
end
end
end
trait :with_attestation do
after(:create) do |dossier, _evaluator|
if dossier.procedure.attestation_template.blank?
dossier.procedure.attestation_template = create(:attestation_template)
end
dossier.attestation = dossier.build_attestation
end
end
end
end

View file

@ -67,6 +67,11 @@ describe 'new_user/dossiers/show/_status_overview.html.haml', type: :view do
it { is_expected.not_to have_selector('.status-timeline') }
it { is_expected.to have_selector('.status-explanation .accepte') }
it { is_expected.to have_text(dossier.motivation) }
context 'with attestation' do
let(:dossier) { create :dossier, :accepte, :with_attestation }
it { is_expected.to have_link(nil, href: attestation_dossier_path(dossier)) }
end
end
context 'when refusé' do