feat(dossier): add dossier id to prefill response (#8382)
This commit is contained in:
parent
88518fed49
commit
177dec2bdb
4 changed files with 14 additions and 7 deletions
|
@ -11,7 +11,11 @@ class API::Public::V1::DossiersController < API::Public::V1::BaseController
|
|||
dossier.build_default_individual
|
||||
if dossier.save
|
||||
dossier.prefill!(PrefillParams.new(dossier, params.to_unsafe_h).to_a)
|
||||
render json: { dossier_url: commencer_url(@procedure.path, prefill_token: dossier.prefill_token) }, status: :created
|
||||
render json: {
|
||||
dossier_url: commencer_url(@procedure.path, prefill_token: dossier.prefill_token),
|
||||
dossier_id: dossier.to_typed_id,
|
||||
dossier_number: dossier.id
|
||||
}, status: :created
|
||||
else
|
||||
render_bad_request(dossier.errors.full_messages.to_sentence)
|
||||
end
|
||||
|
|
|
@ -139,7 +139,7 @@ en:
|
|||
prefill_link_copy: Copy prefill link
|
||||
prefill_query_title: Prefill query (POST)
|
||||
prefill_query_info: Use the button to copy the query, then remplace the values with your data.
|
||||
prefill_query_response_html: '# Response:<br># {"dossier_url":"%{url}"}'
|
||||
prefill_query_response_html: '# Response:<br># {<br># "dossier_url": "%{url}",<br># "dossier_id": "aBase64Id==",<br># "dossier_number": 42<br># }'
|
||||
prefill_query_copy: Copy prefill query
|
||||
registrations:
|
||||
new:
|
||||
|
|
|
@ -132,7 +132,7 @@ fr:
|
|||
prefill_link_copy: Copier le lien de préremplissage
|
||||
prefill_query_title: Requête de préremplissage (POST)
|
||||
prefill_query_info: Copiez la requête grâce au bouton ci-dessous et remplacez les valeurs par les données dont vous disposez.
|
||||
prefill_query_response_html: '# Response:<br># {"dossier_url":"%{url}"}'
|
||||
prefill_query_response_html: '# Response:<br># {<br># "dossier_url": "%{url}",<br># "dossier_id": "aBase64Id==",<br># "dossier_number": 42<br># }'
|
||||
prefill_query_copy: Copier la requête de préremplissage
|
||||
registrations:
|
||||
new:
|
||||
|
|
|
@ -30,11 +30,14 @@ RSpec.describe API::Public::V1::DossiersController, type: :controller do
|
|||
expect(Dossier.last.user).to eq(nil)
|
||||
end
|
||||
|
||||
it "responds with the brouillon dossier path" do
|
||||
it "responds with the brouillon dossier url and id" do
|
||||
create_request
|
||||
expect(JSON.parse(response.body)["dossier_url"]).to eq(
|
||||
"http://test.host#{commencer_path(procedure.path, prefill_token: Dossier.last.prefill_token)}"
|
||||
)
|
||||
|
||||
dossier = Dossier.last
|
||||
dossier_url = "http://test.host#{commencer_path(procedure.path, prefill_token: dossier.prefill_token)}"
|
||||
expect(JSON.parse(response.body)["dossier_url"]).to eq(dossier_url)
|
||||
expect(JSON.parse(response.body)["dossier_id"]).to eq(dossier.to_typed_id)
|
||||
expect(JSON.parse(response.body)["dossier_number"]).to eq(dossier.id)
|
||||
end
|
||||
|
||||
context 'when prefill values are given' do
|
||||
|
|
Loading…
Reference in a new issue