test(attestation): preview pdf

This commit is contained in:
Colin Darie 2024-06-07 12:06:41 +02:00
parent 70aee9c9de
commit a2c0379127
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4

View file

@ -31,11 +31,12 @@ describe Administrateurs::AttestationTemplateV2sController, type: :controller do
describe 'GET #show' do
subject do
get :show, params: { procedure_id: procedure.id }
get :show, params: { procedure_id: procedure.id, format: }
response.body
end
context 'if an attestation template exists on the procedure' do
context 'html' do
let(:format) { :html }
render_views
context 'with preview dossier' do
@ -93,6 +94,24 @@ describe Administrateurs::AttestationTemplateV2sController, type: :controller do
end
end
end
context 'pdf' do
render_views
let(:format) { :pdf }
let(:attestation_template) { build(:attestation_template, :v2, signature:) }
let(:dossier) { create(:dossier, :en_construction, procedure:, for_procedure_preview: true) }
before do
html_content = /Ministère des devs.+Mon titre pour Ma démarche.+n° #{dossier.id}/m
context = { procedure_id: procedure.id }
allow(WeasyprintService).to receive(:generate_pdf).with(a_string_matching(html_content), hash_including(context)).and_return('PDF_DATA')
end
it do
is_expected.to eq('PDF_DATA')
end
end
end
describe 'GET edit' do