dossier: add new page for SIRET identification

This commit is contained in:
Pierre de La Morinerie 2018-10-04 09:43:19 +02:00 committed by gregoirenovel
parent 1cf7568bb4
commit 54ba0f8e50
8 changed files with 70 additions and 5 deletions

View file

@ -69,6 +69,10 @@ module NewUser
end end
end end
def siret
@dossier = dossier
end
def brouillon def brouillon
@dossier = dossier_with_champs @dossier = dossier_with_champs
@ -77,7 +81,7 @@ module NewUser
if dossier.procedure.for_individual if dossier.procedure.for_individual
redirect_to identite_dossier_path(@dossier) redirect_to identite_dossier_path(@dossier)
else else
redirect_to users_dossier_path(@dossier) redirect_to siret_dossier_path(@dossier)
end end
end end
end end

View file

@ -61,7 +61,7 @@ class Users::DossiersController < UsersController
if dossier.procedure.for_individual if dossier.procedure.for_individual
redirect_to identite_dossier_path(dossier) redirect_to identite_dossier_path(dossier)
else else
redirect_to users_dossier_path(id: dossier.id) redirect_to siret_dossier_path(id: dossier.id)
end end
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
error_procedure error_procedure

View file

@ -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…" }

View file

@ -113,6 +113,7 @@ fr:
activerecord: activerecord:
attributes: attributes:
user: user:
siret: 'Numéro SIRET'
password: 'Le mot de passe' password: 'Le mot de passe'
gestionnaire: gestionnaire:
password: 'Le mot de passe' password: 'Le mot de passe'

View file

@ -278,6 +278,7 @@ Rails.application.routes.draw do
member do member do
get 'identite' get 'identite'
patch 'update_identite' patch 'update_identite'
get 'siret'
get 'brouillon' get 'brouillon'
patch 'brouillon', to: 'dossiers#update_brouillon' patch 'brouillon', to: 'dossiers#update_brouillon'
get 'modifier', to: 'dossiers#modifier' get 'modifier', to: 'dossiers#modifier'

View file

@ -205,6 +205,15 @@ describe NewUser::DossiersController, type: :controller do
end end
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 describe '#brouillon' do
before { sign_in(user) } before { sign_in(user) }
let!(:dossier) { create(:dossier, user: user, autorisation_donnees: true) } 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) } before { dossier.update_columns(autorisation_donnees: false) }
context 'when the dossier is for personne morale' do 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 end
context 'when the dossier is for an personne physique' do context 'when the dossier is for an personne physique' do

View file

@ -61,7 +61,7 @@ describe Users::DossiersController, type: :controller do
end end
it { is_expected.to have_http_status(302) } 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 } 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 } } subject { get :new, params: { procedure_id: procedure_id, brouillon: true } }
it { is_expected.to have_http_status(302) } 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 end
end end

View file

@ -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