DossiersController: add get procedure libelle
This commit is contained in:
parent
d531ed057c
commit
ed36897337
3 changed files with 33 additions and 0 deletions
|
@ -154,6 +154,13 @@ class Users::DossiersController < UsersController
|
|||
redirect_to url_for users_dossiers_path
|
||||
end
|
||||
|
||||
def procedure_libelle
|
||||
dossier = Dossier.find(params[:dossier_id])
|
||||
render json: { procedureLibelle: dossier.procedure.libelle }
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render json: {}, status: 404
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_siret
|
||||
|
|
|
@ -94,6 +94,8 @@ Rails.application.routes.draw do
|
|||
|
||||
post '/siret_informations' => 'dossiers#siret_informations'
|
||||
put '/change_siret' => 'dossiers#change_siret'
|
||||
|
||||
get 'procedure_libelle' => 'dossiers#procedure_libelle'
|
||||
end
|
||||
resource :dossiers
|
||||
end
|
||||
|
|
|
@ -554,4 +554,28 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'Get #procedure_libelle' do
|
||||
let!(:dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
context 'when user is connected' do
|
||||
before { sign_in user }
|
||||
|
||||
context 'when the dossier exist' do
|
||||
before { get :procedure_libelle, params: { dossier_id: dossier.id } }
|
||||
it 'returns the procedure name' do
|
||||
expect(JSON.parse(response.body)).to eq('procedureLibelle' => procedure.libelle)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the dossier does not exist' do
|
||||
before { get :procedure_libelle, params: { dossier_id: 666 } }
|
||||
it { expect(response.code).to eq('404') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is not connected' do
|
||||
before { get :procedure_libelle, params: { dossier_id: dossier.id } }
|
||||
it { expect(response.code).to eq('302') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue