raise Error if generation fail
This commit is contained in:
parent
76f7222e7a
commit
46087e4577
2 changed files with 12 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -65,7 +65,12 @@ describe 'As an administrateur, I want to manage the procedure’s 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)
|
||||
|
|
Loading…
Reference in a new issue