raise Error if generation fail

This commit is contained in:
simon lehericey 2024-03-14 14:04:43 +01:00
parent 76f7222e7a
commit 46087e4577
2 changed files with 12 additions and 3 deletions

View file

@ -34,9 +34,13 @@ module Administrateurs
}
}.to_json
result = Typhoeus.post(WEASYPRINT_URL, headers:, body:)
response = Typhoeus.post(WEASYPRINT_URL, headers:, body:)
send_data(result.body, filename: 'attestation.pdf', type: 'application/pdf', disposition: 'inline')
if response.success?
send_data(response.body, filename: 'attestation.pdf', type: 'application/pdf', disposition: 'inline')
else
raise StandardError.new("PDF Generation failed: #{response.return_code} #{response.status_message}")
end
end
end
end

View file

@ -65,7 +65,12 @@ describe 'As an administrateur, I want to manage the procedures attestation',
end
context 'Update attestation v2' do
before { Flipper.enable(:attestation_v2) }
before do
Flipper.enable(:attestation_v2)
response = Typhoeus::Response.new(code: 200, body: 'Hello world')
Typhoeus.stub(WEASYPRINT_URL).and_return(response)
end
scenario do
visit admin_procedure_path(procedure)