Merge pull request #1784 from betagouv/remove_individual_logic_from_old_controller
Remove individual logic from old controller
This commit is contained in:
commit
95cb1ec813
4 changed files with 2 additions and 100 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
|
||||
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
- if @facade.procedure.for_individual?
|
||||
= render partial: 'dossiers/etapes/etape_2/individual'
|
||||
- else
|
||||
= render partial: 'dossiers/etapes/etape_2/entreprise'
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
.col-xs-3.center
|
||||
%h3 Mes informations
|
||||
%p
|
||||
Les informations de bases
|
||||
%br
|
||||
vous concernant.
|
||||
|
||||
.etape.etapes-informations.col-xs-9
|
||||
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
|
||||
.row
|
||||
.col-xs-12.padding-left-30
|
||||
= f.hidden_field :id
|
||||
|
||||
= f.fields_for :individual, @facade.individual do |ff|
|
||||
.form-group
|
||||
%label
|
||||
%h4
|
||||
Civilité
|
||||
= ff.select :gender, ['M.', 'Mme']
|
||||
.form-group
|
||||
%label
|
||||
%h4
|
||||
Nom *
|
||||
= ff.text_field :nom, { class: 'form-control', required: true }
|
||||
.form-group
|
||||
%label
|
||||
%h4
|
||||
Prénom *
|
||||
= ff.text_field :prenom, { class: 'form-control', required: true }
|
||||
|
||||
- if @facade.procedure.ask_birthday?
|
||||
.form-group
|
||||
%label
|
||||
%h4
|
||||
Date de naissance *
|
||||
= ff.date_field :birthdate, { value: @facade.individual.birthdate, class: 'form-control', placeholder: 'jj/mm/aaaa', required: true }
|
||||
|
||||
%p
|
||||
%label{ style: 'font-weight: normal;' }
|
||||
= f.check_box :autorisation_donnees
|
||||
J'accepte
|
||||
= link_to "les CGU", CGU_URL, target: :blank
|
||||
.row
|
||||
.col-xs-5.col-xs-5
|
||||
.col-xs-2.col-xs-2
|
||||
= f.submit 'Etape suivante', class: "action", id: 'etape_suivante'
|
||||
.col-xs-5.col-xs-5
|
|
@ -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…
Reference in a new issue