From 54ba0f8e50f83cbe75bc9184d561cb54321d68df Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 4 Oct 2018 09:43:19 +0200 Subject: [PATCH] dossier: add new page for SIRET identification --- .../new_user/dossiers_controller.rb | 6 ++++- app/controllers/users/dossiers_controller.rb | 2 +- app/views/new_user/dossiers/siret.html.haml | 25 +++++++++++++++++++ config/locales/fr.yml | 1 + config/routes.rb | 1 + .../new_user/dossiers_controller_spec.rb | 11 +++++++- .../users/dossiers_controller_spec.rb | 4 +-- .../new_user/dossiers/siret.html.haml_spec.rb | 25 +++++++++++++++++++ 8 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 app/views/new_user/dossiers/siret.html.haml create mode 100644 spec/views/new_user/dossiers/siret.html.haml_spec.rb diff --git a/app/controllers/new_user/dossiers_controller.rb b/app/controllers/new_user/dossiers_controller.rb index 0aff4993d..bf15d9e15 100644 --- a/app/controllers/new_user/dossiers_controller.rb +++ b/app/controllers/new_user/dossiers_controller.rb @@ -69,6 +69,10 @@ module NewUser end end + def siret + @dossier = dossier + end + def brouillon @dossier = dossier_with_champs @@ -77,7 +81,7 @@ module NewUser if dossier.procedure.for_individual redirect_to identite_dossier_path(@dossier) else - redirect_to users_dossier_path(@dossier) + redirect_to siret_dossier_path(@dossier) end end end diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 9ccffbfad..06b52f3d2 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -61,7 +61,7 @@ class Users::DossiersController < UsersController if dossier.procedure.for_individual redirect_to identite_dossier_path(dossier) else - redirect_to users_dossier_path(id: dossier.id) + redirect_to siret_dossier_path(id: dossier.id) end rescue ActiveRecord::RecordNotFound error_procedure diff --git a/app/views/new_user/dossiers/siret.html.haml b/app/views/new_user/dossiers/siret.html.haml new file mode 100644 index 000000000..4c1a84093 --- /dev/null +++ b/app/views/new_user/dossiers/siret.html.haml @@ -0,0 +1,25 @@ +- content_for(:title, "Nouveau dossier (#{@dossier.procedure.libelle})") + +- content_for :footer do + = render partial: "new_user/dossiers/dossier_footer", locals: { dossier: @dossier } + +.two-columns + .columns-container + .column.preview + = render partial: "new_user/dossiers/demarche_overview", locals: { procedure: @dossier.procedure } + + .column.identity-form + = render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier } + + - if !dossier_submission_is_closed?(@dossier) + = form_for @dossier, url: users_dossier_siret_informations_path(@dossier), html: { class: "form" } do |f| + %h1 Identifier votre établissement + + %p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche. + + = f.label :siret, style: "display: none" + = f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true + + = f.hidden_field :dossier_id, value: @dossier.id + + = f.submit "Valider", class: "button large primary expand", data: { disable_with: "Récupération des informations…" } diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d2c6d7ea2..fa50634b4 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -113,6 +113,7 @@ fr: activerecord: attributes: user: + siret: 'Numéro SIRET' password: 'Le mot de passe' gestionnaire: password: 'Le mot de passe' diff --git a/config/routes.rb b/config/routes.rb index dcb3c729d..38b3e7ae0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -278,6 +278,7 @@ Rails.application.routes.draw do member do get 'identite' patch 'update_identite' + get 'siret' get 'brouillon' patch 'brouillon', to: 'dossiers#update_brouillon' get 'modifier', to: 'dossiers#modifier' diff --git a/spec/controllers/new_user/dossiers_controller_spec.rb b/spec/controllers/new_user/dossiers_controller_spec.rb index ba818a0eb..7ba78e32c 100644 --- a/spec/controllers/new_user/dossiers_controller_spec.rb +++ b/spec/controllers/new_user/dossiers_controller_spec.rb @@ -205,6 +205,15 @@ describe NewUser::DossiersController, type: :controller do end end + describe '#siret' do + before { sign_in(user) } + let!(:dossier) { create(:dossier, user: user) } + + subject { get :siret, params: { id: dossier.id } } + + it { is_expected.to render_template(:siret) } + end + describe '#brouillon' do before { sign_in(user) } let!(:dossier) { create(:dossier, user: user, autorisation_donnees: true) } @@ -219,7 +228,7 @@ describe NewUser::DossiersController, type: :controller do before { dossier.update_columns(autorisation_donnees: false) } context 'when the dossier is for personne morale' do - it { is_expected.to redirect_to(users_dossier_path(dossier)) } + it { is_expected.to redirect_to(siret_dossier_path(dossier)) } end context 'when the dossier is for an personne physique' do diff --git a/spec/controllers/users/dossiers_controller_spec.rb b/spec/controllers/users/dossiers_controller_spec.rb index 6201d9de0..cac2d12f4 100644 --- a/spec/controllers/users/dossiers_controller_spec.rb +++ b/spec/controllers/users/dossiers_controller_spec.rb @@ -61,7 +61,7 @@ describe Users::DossiersController, type: :controller do end it { is_expected.to have_http_status(302) } - it { is_expected.to redirect_to users_dossier_path(id: Dossier.last) } + it { is_expected.to redirect_to siret_dossier_path(id: Dossier.last) } it { expect { subject }.to change(Dossier, :count).by 1 } @@ -152,7 +152,7 @@ describe Users::DossiersController, type: :controller do subject { get :new, params: { procedure_id: procedure_id, brouillon: true } } it { is_expected.to have_http_status(302) } - it { is_expected.to redirect_to users_dossier_path(id: Dossier.last) } + it { is_expected.to redirect_to siret_dossier_path(id: Dossier.last) } end end end diff --git a/spec/views/new_user/dossiers/siret.html.haml_spec.rb b/spec/views/new_user/dossiers/siret.html.haml_spec.rb new file mode 100644 index 000000000..4b003ba33 --- /dev/null +++ b/spec/views/new_user/dossiers/siret.html.haml_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe 'new_user/dossiers/siret.html.haml', type: :view do + let(:dossier) { create(:dossier) } + let(:footer) { view.content_for(:footer) } + + before do + sign_in dossier.user + assign(:dossier, dossier) + end + + subject! { render } + + it 'affiche les informations de la démarche' do + expect(rendered).to have_text(dossier.procedure.libelle) + end + + it 'affiche le formulaire de SIRET' do + expect(rendered).to have_field('Numéro SIRET') + end + + it 'prépare le footer' do + expect(footer).to have_selector('footer') + end +end