Individual: old controller does not care about individual anymore
This commit is contained in:
parent
9749365cc7
commit
46fd213ad2
2 changed files with 1 additions and 49 deletions
|
@ -148,7 +148,7 @@ class Users::DossiersController < UsersController
|
|||
flash.alert = individual_errors
|
||||
redirect_to users_dossier_path(id: @facade.dossier.id)
|
||||
else
|
||||
if !Dossier.find(@facade.dossier.id).update update_params_with_formatted_birthdate
|
||||
if !Dossier.find(@facade.dossier.id).update(update_params)
|
||||
flash.alert = @facade.dossier.errors.full_messages
|
||||
|
||||
return redirect_to users_dossier_path(id: @facade.dossier.id)
|
||||
|
@ -201,24 +201,6 @@ class Users::DossiersController < UsersController
|
|||
params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:gender, :nom, :prenom, :birthdate])
|
||||
end
|
||||
|
||||
def update_params_with_formatted_birthdate
|
||||
editable_params = update_params
|
||||
|
||||
if editable_params &&
|
||||
editable_params[:individual_attributes] &&
|
||||
editable_params[:individual_attributes][:birthdate]
|
||||
|
||||
iso_date = begin
|
||||
Date.parse(editable_params[:individual_attributes][:birthdate]).iso8601
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
editable_params[:individual_attributes][:birthdate] = iso_date
|
||||
end
|
||||
|
||||
editable_params
|
||||
end
|
||||
|
||||
def individual_errors
|
||||
errors = []
|
||||
|
||||
|
@ -226,13 +208,6 @@ class Users::DossiersController < UsersController
|
|||
errors << "La validation des conditions d'utilisation est obligatoire"
|
||||
end
|
||||
|
||||
if update_params[:individual_attributes].present? &&
|
||||
update_params[:individual_attributes][:birthdate] &&
|
||||
!/^\d{4}\-\d{2}\-\d{2}$/.match(update_params[:individual_attributes][:birthdate]) &&
|
||||
!/^\d{2}\/\d{2}\/\d{4}$/.match(update_params[:individual_attributes][:birthdate])
|
||||
errors << "Le format de la date de naissance doit être JJ/MM/AAAA"
|
||||
end
|
||||
|
||||
errors
|
||||
end
|
||||
|
||||
|
|
|
@ -345,29 +345,6 @@ describe Users::DossiersController, type: :controller do
|
|||
subject
|
||||
end
|
||||
|
||||
context 'when procedure is for individual' do
|
||||
let(:autorisation_donnees) { "1" }
|
||||
let(:procedure) { create(:procedure, :published, for_individual: true) }
|
||||
|
||||
before do
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
it { expect(dossier.individual.gender).to eq 'M.' }
|
||||
it { expect(dossier.individual.nom).to eq 'Julien' }
|
||||
it { expect(dossier.individual.prenom).to eq 'Xavier' }
|
||||
it { expect(dossier.individual.birthdate).to eq '1991-01-20' }
|
||||
it { expect(dossier.procedure.for_individual).to eq true }
|
||||
|
||||
context "and birthdate is ISO (YYYY-MM-DD) formatted" do
|
||||
let(:birthdate) { "1991-11-01" }
|
||||
before do
|
||||
dossier.reload
|
||||
end
|
||||
it { expect(dossier.individual.birthdate).to eq '1991-11-01' }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when Checkbox is checked' do
|
||||
let(:autorisation_donnees) { '1' }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue