- delete route '/users/siret'
- delete route 'users/procedure' - create route 'users/dossiers/new?procedure_id=:procedure_id' - delete a part of unused code - adapt demo page with new procedure URL
This commit is contained in:
parent
851f4e830e
commit
afaa6a5ac9
19 changed files with 166 additions and 333 deletions
|
@ -1,4 +1,3 @@
|
|||
function show_dossier_id_input (){
|
||||
$("#btn_show_dossier_id_input").hide()
|
||||
$("#pro_dossier_id").show()
|
||||
}
|
|
@ -6,6 +6,13 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
#dossier_siret {
|
||||
margin-bottom: 10px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
#titre_procedure {
|
||||
margin-top: 3%;
|
||||
margin-bottom: 2%;
|
||||
|
|
|
@ -3,10 +3,13 @@ class RootController < ApplicationController
|
|||
|
||||
if user_signed_in?
|
||||
redirect_to users_dossiers_path
|
||||
|
||||
elsif gestionnaire_signed_in?
|
||||
redirect_to backoffice_dossiers_path
|
||||
|
||||
elsif administrateur_signed_in?
|
||||
redirect_to admin_procedures_path
|
||||
|
||||
else
|
||||
redirect_to new_user_session_path
|
||||
end
|
||||
|
|
|
@ -28,6 +28,16 @@ class Users::DossiersController < UsersController
|
|||
total_dossiers_per_state
|
||||
end
|
||||
|
||||
def new
|
||||
procedure = Procedure.where(archived: false).find(params[:procedure_id])
|
||||
|
||||
@dossier = Dossier.new(procedure: procedure)
|
||||
@siret = params[:siret] || current_user.siret
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
error_procedure
|
||||
end
|
||||
|
||||
def show
|
||||
@dossier = current_user_dossier params[:id]
|
||||
|
||||
|
@ -35,7 +45,7 @@ class Users::DossiersController < UsersController
|
|||
@entreprise = @dossier.entreprise.decorate
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: :siret)
|
||||
redirect_to url_for users_dossiers_path
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -52,7 +62,7 @@ class Users::DossiersController < UsersController
|
|||
end
|
||||
end
|
||||
|
||||
@dossier = Dossier.create(user: current_user, state: 'draft', procedure_id: params['procedure_id'])
|
||||
@dossier = Dossier.create(user: current_user, state: 'draft', procedure_id: create_params[:procedure_id])
|
||||
|
||||
@entreprise.dossier = @dossier
|
||||
@entreprise.save
|
||||
|
@ -65,7 +75,8 @@ class Users::DossiersController < UsersController
|
|||
|
||||
rescue RestClient::ResourceNotFound
|
||||
flash.alert = t('errors.messages.invalid_siret')
|
||||
redirect_to url_for(controller: :siret, procedure_id: params['procedure_id'])
|
||||
redirect_to url_for new_users_dossiers_path(procedure_id: create_params[:procedure_id])
|
||||
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
flash.alert = t('errors.messages.dossier_not_found')
|
||||
redirect_to url_for(controller: :siret)
|
||||
|
@ -117,7 +128,7 @@ class Users::DossiersController < UsersController
|
|||
end
|
||||
|
||||
def siret
|
||||
params[:siret]
|
||||
create_params[:siret]
|
||||
end
|
||||
|
||||
def siren
|
||||
|
@ -129,4 +140,12 @@ class Users::DossiersController < UsersController
|
|||
@dossiers_en_attente_total = !@dossiers_en_attente.nil? ? @dossiers_en_attente.size : current_user.dossiers.waiting_for_gestionnaire.size
|
||||
@dossiers_termine_total = !@dossiers_termine.nil? ? @dossiers_termine.size : current_user.dossiers.termine.size
|
||||
end
|
||||
|
||||
def create_params
|
||||
params.require(:dossier).permit(:siret, :procedure_id)
|
||||
end
|
||||
|
||||
def error_procedure
|
||||
render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
class Users::ProcedureController < UsersController
|
||||
def index
|
||||
@procedure = Procedure.where(archived: false).find(params[:procedure_id])
|
||||
@siret = params[:siret] || current_user.siret
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
error_procedure
|
||||
end
|
||||
|
||||
def error_procedure
|
||||
render :file => "#{Rails.root}/public/404_procedure_not_found.html", :status => 404
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
class Users::SiretController < UsersController
|
||||
def index
|
||||
@siret = params[:siret] || current_user.siret
|
||||
|
||||
redirect_to(users_path(procedure_id: params['procedure_id'], siret: @siret))
|
||||
rescue ActionController::UrlGenerationError
|
||||
redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
|
@ -18,7 +18,7 @@ class Dossier < ActiveRecord::Base
|
|||
has_many :commentaires, dependent: :destroy
|
||||
|
||||
delegate :siren, to: :entreprise
|
||||
delegate :siret, to: :etablissement
|
||||
delegate :siret, to: :etablissement, allow_nil: true
|
||||
delegate :types_de_piece_justificative, to: :procedure
|
||||
delegate :types_de_champ, to: :procedure
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
%td
|
||||
= procedure.id
|
||||
%td.col-md-4.col-lg-4
|
||||
= link_to procedure.libelle, "/users/procedure/#{procedure.id}"
|
||||
= link_to procedure.libelle, "/users/dossiers/new?procedure_id=#{procedure.id}"
|
||||
%td
|
||||
= procedure.description
|
||||
%td.col-md-3.col-lg-3
|
||||
|
|
19
app/views/users/dossiers/new.html.haml
Normal file
19
app/views/users/dossiers/new.html.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
.container.center#users_siret_index
|
||||
.row
|
||||
%p.lead{id: 'pro_section'}
|
||||
%br
|
||||
= image_tag('logo-tps.png')
|
||||
%br
|
||||
%h2#titre_procedure.text-info
|
||||
= @dossier.procedure.libelle
|
||||
|
||||
%p
|
||||
= @dossier.procedure.description
|
||||
|
||||
%br
|
||||
|
||||
= form_for @dossier, url: {controller: 'users/dossiers', action: :create}, method: :post do |f|
|
||||
.form-group.form-group-lg
|
||||
= f.text_field :siret, class: "form-control", placeholder: "Entrez votre Siret", value: @siret
|
||||
= f.hidden_field :procedure_id
|
||||
= f.submit 'Commencer', class: %w(btn btn-lg btn-success), style: 'margin-top:20px;'
|
|
@ -1,17 +0,0 @@
|
|||
%p.lead{id: 'pro_section'}
|
||||
%br
|
||||
= image_tag('logo-tps.png')
|
||||
%br
|
||||
%h2#titre_procedure.text-info
|
||||
= @procedure.libelle
|
||||
|
||||
%p
|
||||
= @procedure.description
|
||||
|
||||
%br
|
||||
= form_tag(url_for({controller: :dossiers, action: :create}), class: 'form-inline', method: 'POST') do |f|
|
||||
.form-group.form-group-lg
|
||||
= text_field_tag :siret, nil, :class => "form-control", :placeholder => "Entrez votre Siret", :id => "siret", :name => "siret", :maxlength => 14, :style => 'margin-bottom:10px', value: @siret
|
||||
%br
|
||||
= submit_tag "Commencer", class: %w(btn btn-lg btn-success), style: 'margin-top:20px;', data: { disable_with: "Commencer", submit: true}
|
||||
%input{type: 'hidden', value: "#{@procedure.id}", name: 'procedure_id', id: 'procedure_id'}
|
|
@ -1,4 +0,0 @@
|
|||
.container.center#users_siret_index
|
||||
.row
|
||||
= render partial: 'pro'
|
||||
|
|
@ -21,9 +21,6 @@ Rails.application.routes.draw do
|
|||
get 'demo' => 'demo#index'
|
||||
|
||||
namespace :users do
|
||||
get 'siret' => 'siret#index'
|
||||
get 'procedure/:procedure_id' => 'procedure#index'
|
||||
|
||||
resources :dossiers do
|
||||
get '/description' => 'description#show'
|
||||
get '/description/error' => 'description#error'
|
||||
|
|
|
@ -1,124 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DossiersController, type: :controller do
|
||||
# let(:dossier) { create(:dossier, :with_entreprise, :with_procedure) }
|
||||
# let(:procedure) { create(:procedure) }
|
||||
# let(:dossier_id) { dossier.id }
|
||||
# let(:siret_not_found) { 999_999_999_999 }
|
||||
|
||||
# let(:siren) { dossier.siren }
|
||||
# let(:siret) { dossier.siret }
|
||||
# let(:bad_siret) { 1 }
|
||||
|
||||
# describe 'GET #show' do
|
||||
# it 'returns http success with dossier_id valid' do
|
||||
# get :show, id: dossier_id
|
||||
# expect(response).to have_http_status(:success)
|
||||
# end
|
||||
|
||||
# it 'redirection vers siret si mauvais dossier ID' do
|
||||
# get :show, id: siret_not_found
|
||||
# expect(response).to redirect_to('/siret')
|
||||
# end
|
||||
# end
|
||||
|
||||
# describe 'POST #create' do
|
||||
# before do
|
||||
# stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret_not_found}?token=#{SIADETOKEN}")
|
||||
# .to_return(status: 404, body: 'fake body')
|
||||
|
||||
# stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/#{siret}?token=#{SIADETOKEN}")
|
||||
# .to_return(status: 200, body: File.read('spec/support/files/etablissement.json'))
|
||||
|
||||
# stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/entreprises/#{siren}?token=#{SIADETOKEN}")
|
||||
# .to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||
# end
|
||||
|
||||
# describe 'professionnel fills form' do
|
||||
# context 'when pro_dossier_id is empty' do
|
||||
# context 'with valid siret ' do
|
||||
|
||||
# subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
|
||||
|
||||
|
||||
# it 'create a dossier' do
|
||||
# expect { subject }.to change { Dossier.count }.by(1)
|
||||
# end
|
||||
|
||||
# it 'creates entreprise' do
|
||||
# expect { subject }.to change { Entreprise.count }.by(1)
|
||||
# end
|
||||
|
||||
# it 'links entreprise to dossier' do
|
||||
# expect(Entreprise.last.dossier).to eq(Dossier.last)
|
||||
# end
|
||||
|
||||
# it 'creates etablissement for dossier' do
|
||||
# expect { subject }.to change { Etablissement.count }.by(1)
|
||||
# end
|
||||
|
||||
# it 'links etablissement to dossier' do
|
||||
# subject
|
||||
# expect(Etablissement.last.dossier).to eq(Dossier.last)
|
||||
# end
|
||||
|
||||
# it 'links etablissement to entreprise' do
|
||||
# subject
|
||||
# expect(Etablissement.last.entreprise).to eq(Entreprise.last)
|
||||
# end
|
||||
|
||||
# it 'links procedure to dossier' do
|
||||
# subject
|
||||
# expect(Dossier.last.procedure).to eq(Procedure.last)
|
||||
# end
|
||||
|
||||
# it 'state of dossier is draft' do
|
||||
# subject
|
||||
# expect(Dossier.last.state).to eq('draft')
|
||||
# end
|
||||
# end
|
||||
|
||||
# context 'with non existant siret' do
|
||||
# let(:siret_not_found) { '11111111111111' }
|
||||
# subject { post :create, siret: siret_not_found, pro_dossier_id: '', procedure_id: procedure.id }
|
||||
# it 'does not create new dossier' do
|
||||
# expect { subject }.not_to change { Dossier.count }
|
||||
# end
|
||||
|
||||
# it 'redirects to show' do
|
||||
# expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# describe 'PUT #update' do
|
||||
# before do
|
||||
# put :update, id: dossier_id, dossier: { autorisation_donnees: autorisation_donnees }
|
||||
# end
|
||||
# context 'when Checkbox is checked' do
|
||||
# let(:autorisation_donnees) { '1' }
|
||||
# it 'redirects to demande' do
|
||||
# expect(response).to redirect_to(controller: :description, action: :show, dossier_id: dossier.id)
|
||||
# end
|
||||
|
||||
# it 'update dossier' do
|
||||
# dossier.reload
|
||||
# expect(dossier.autorisation_donnees).to be_truthy
|
||||
# end
|
||||
# end
|
||||
|
||||
# context 'when Checkbox is not checked' do
|
||||
# let(:autorisation_donnees) { '0' }
|
||||
# it 'uses flash alert to display message' do
|
||||
# expect(flash[:alert]).to have_content('Les conditions sont obligatoires.')
|
||||
# end
|
||||
|
||||
# it "doesn't update dossier autorisation_donnees" do
|
||||
# dossier.reload
|
||||
# expect(dossier.autorisation_donnees).to be_falsy
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,7 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
let(:use_api_carto) { false }
|
||||
let(:procedure) { create(:procedure, use_api_carto: use_api_carto) }
|
||||
let(:procedure_id) { procedure.id }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
let(:siret_not_found) { 999_999_999_999 }
|
||||
|
@ -22,9 +23,44 @@ describe Users::DossiersController, type: :controller do
|
|||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
it 'redirection vers siret si mauvais dossier ID' do
|
||||
it 'redirection vers liste dossier si mauvais dossier ID' do
|
||||
get :show, id: siret_not_found
|
||||
expect(response).to redirect_to('/users/siret')
|
||||
expect(response).to redirect_to('/users/dossiers')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
subject { get :new, procedure_id: procedure_id }
|
||||
|
||||
context 'when params procedure_id is present' do
|
||||
context 'when procedure_id is valid' do
|
||||
context 'when user is logged in' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
|
||||
it { is_expected.to have_http_status(:success) }
|
||||
|
||||
context 'when procedure is archived' do
|
||||
let(:procedure) { create(:procedure, archived: 'true') }
|
||||
|
||||
it { is_expected.to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
context 'when user is not logged' do
|
||||
it { is_expected.to have_http_status(302) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when procedure_id is not valid' do
|
||||
let(:procedure_id) { 0 }
|
||||
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
|
||||
it { is_expected.to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -45,13 +81,12 @@ describe Users::DossiersController, type: :controller do
|
|||
|
||||
describe 'professionnel fills form' do
|
||||
let(:user) { create(:user) }
|
||||
context 'when pro_dossier_id is empty' do
|
||||
context 'with valid siret ' do
|
||||
before do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
subject { post :create, siret: siret, pro_dossier_id: '', procedure_id: Procedure.last }
|
||||
subject { post :create, dossier: {siret: siret, procedure_id: Procedure.last} }
|
||||
|
||||
|
||||
it 'create a dossier' do
|
||||
|
@ -108,14 +143,13 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
|
||||
let(:siret_not_found) { '11111111111111' }
|
||||
subject { post :create, siret: siret_not_found, pro_dossier_id: '', procedure_id: procedure.id }
|
||||
subject { post :create, dossier: {siret: siret_not_found, procedure_id: procedure.id} }
|
||||
it 'does not create new dossier' do
|
||||
expect { subject }.not_to change { Dossier.count }
|
||||
end
|
||||
|
||||
it 'redirects to show' do
|
||||
expect(subject).to redirect_to(controller: :siret, procedure_id: procedure.id)
|
||||
end
|
||||
expect(subject).to redirect_to new_users_dossiers_path(procedure_id: procedure_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::ProcedureController, type: :controller do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:procedure_id) { procedure.id }
|
||||
|
||||
describe 'GET #index' do
|
||||
|
||||
subject { get :index, procedure_id: procedure_id }
|
||||
|
||||
context 'when params procedure_id is present' do
|
||||
context 'when procedure_id is valid' do
|
||||
context 'when user is logged in' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
|
||||
it { is_expected.to have_http_status(:success) }
|
||||
|
||||
context 'when procedure is archived' do
|
||||
let(:procedure) { create(:procedure, archived: 'true') }
|
||||
|
||||
it { is_expected.to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
context 'when user is not logged' do
|
||||
it { is_expected.to have_http_status(302) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when procedure_id is not valid' do
|
||||
let(:procedure_id) { 0 }
|
||||
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
|
||||
it { is_expected.to have_http_status(404) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,42 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Users::SiretController, type: :controller do
|
||||
let!(:procedure) { create(:procedure) }
|
||||
|
||||
describe 'GET #index' do
|
||||
before do
|
||||
get :index, procedure_id: procedure
|
||||
end
|
||||
|
||||
context 'when params procedure_id is present' do
|
||||
context 'when procedure_id is valid' do
|
||||
context 'when user is logged in' do
|
||||
before do
|
||||
sign_in create(:user)
|
||||
end
|
||||
subject { get :index, procedure_id: procedure }
|
||||
|
||||
it { expect(subject).to redirect_to(users_path(procedure_id: procedure.id)) }
|
||||
|
||||
context 'when params siret is present' do
|
||||
subject { get :index, procedure_id: procedure, siret: '123456789' }
|
||||
|
||||
it { expect(subject).to redirect_to(users_path(procedure_id: procedure.id, siret: '123456789')) }
|
||||
end
|
||||
|
||||
context 'when procedure_id is not valid' do
|
||||
let(:procedure) { '' }
|
||||
it { is_expected.to have_http_status(302) }
|
||||
end
|
||||
context 'when params procedure_id is not present' do
|
||||
subject { get :index }
|
||||
it { is_expected.to redirect_to new_user_session_path }
|
||||
end
|
||||
end
|
||||
context 'when user is not logged' do
|
||||
it { expect(response).to have_http_status(302) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -68,13 +68,13 @@ feature 'France Connect Connexion' do
|
|||
end
|
||||
context 'when starting page is procedure' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:initial_path) { users_siret_path(procedure_id: procedure.id ) }
|
||||
let(:initial_path) { new_users_dossiers_path(procedure_id: procedure.id ) }
|
||||
scenario 'he is redirected to siret page' do
|
||||
expect(page).to have_css('#users_siret_index')
|
||||
end
|
||||
|
||||
scenario 'the siret is already written in form' do
|
||||
expect(page.find_by_id('siret').value).to have_content(siret)
|
||||
expect(page.find_by_id('dossier_siret').value).to have_content(siret)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ feature 'user path for dossier creation' do
|
|||
let(:siren) { siret[0...9] }
|
||||
context 'user arrives on siret page' do
|
||||
before do
|
||||
visit users_siret_path(procedure_id: procedure.id)
|
||||
visit new_users_dossiers_path(procedure_id: procedure.id)
|
||||
end
|
||||
|
||||
scenario 'he is redirected on login page' do
|
||||
|
@ -23,7 +23,7 @@ feature 'user path for dossier creation' do
|
|||
end
|
||||
end
|
||||
scenario 'redirects to siret page' do
|
||||
expect(page).to have_css('#siret')
|
||||
expect(page).to have_css('#dossier_siret')
|
||||
end
|
||||
context 'sets siret' do
|
||||
before do
|
||||
|
@ -34,7 +34,7 @@ feature 'user path for dossier creation' do
|
|||
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
||||
page.find_by_id('siret').set siret
|
||||
page.find_by_id('dossier_siret').set siret
|
||||
page.click_on 'Commencer'
|
||||
end
|
||||
scenario 'user is on page recap info entreprise' do
|
||||
|
|
|
@ -7,7 +7,7 @@ feature 'user arrive on siret page' do
|
|||
let(:siren) { siret[0...9] }
|
||||
context 'when user is not logged in' do
|
||||
before do
|
||||
visit users_siret_path(procedure_id: procedure.id)
|
||||
visit new_users_dossiers_path(procedure_id: procedure.id)
|
||||
end
|
||||
scenario 'he is redirected to login page' do
|
||||
expect(page).to have_css('#login_user')
|
||||
|
@ -31,7 +31,7 @@ feature 'user arrive on siret page' do
|
|||
.to_return(status: 200, body: File.read('spec/support/files/entreprise.json'))
|
||||
stub_request(:get, "https://api-dev.apientreprise.fr/api/v1/etablissements/exercices/#{siret}?token=#{SIADETOKEN}")
|
||||
.to_return(status: 200, body: File.read('spec/support/files/exercices.json'))
|
||||
page.find_by_id('siret').set siret
|
||||
page.find_by_id('dossier_siret').set siret
|
||||
page.click_on 'Commencer'
|
||||
end
|
||||
scenario 'he is redirected to recap info entreprise page' do
|
||||
|
|
Loading…
Reference in a new issue