- create route /users/procedure/:procedure_id to replace /users/siret/?procedure_id=
- /users/siret/ redirect to /users/procedure/ - siren can be past on the URL /users/siret and /users/procedure
This commit is contained in:
parent
18d72745f0
commit
db346fb66f
7 changed files with 79 additions and 50 deletions
12
app/controllers/users/procedure_controller.rb
Normal file
12
app/controllers/users/procedure_controller.rb
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class Users::ProcedureController < UsersController
|
||||||
|
def index
|
||||||
|
@procedure = Procedure.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,7 +1,10 @@
|
||||||
class Users::SiretController < UsersController
|
class Users::SiretController < UsersController
|
||||||
def index
|
def index
|
||||||
@procedure = Procedure.find(params['procedure_id'])
|
@procedure = Procedure.find(params['procedure_id'])
|
||||||
@siret = current_user.siret
|
@siret = params[:siret] || current_user.siret
|
||||||
|
|
||||||
|
redirect_to(users_path(procedure_id: @procedure, siret: @siret))
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
error_procedure
|
error_procedure
|
||||||
end
|
end
|
||||||
|
|
17
app/views/users/procedure/_pro.html.haml
Normal file
17
app/views/users/procedure/_pro.html.haml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
%p.lead{id: 'pro_section'}
|
||||||
|
|
||||||
|
= 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'}
|
4
app/views/users/procedure/index.html.haml
Normal file
4
app/views/users/procedure/index.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
.container.center#users_siret_index
|
||||||
|
.row
|
||||||
|
= render partial: 'pro'
|
||||||
|
|
|
@ -21,6 +21,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
namespace :users do
|
namespace :users do
|
||||||
get 'siret' => 'siret#index'
|
get 'siret' => 'siret#index'
|
||||||
|
get 'procedure/:procedure_id' => 'procedure#index'
|
||||||
|
|
||||||
resources :dossiers do
|
resources :dossiers do
|
||||||
get '/description' => 'description#show'
|
get '/description' => 'description#show'
|
||||||
|
|
32
spec/controllers/users/procedure_controller_spec.rb
Normal file
32
spec/controllers/users/procedure_controller_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Users::ProcedureController, 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 have_http_status(:success) }
|
||||||
|
|
||||||
|
context 'when procedure_id is not valid' do
|
||||||
|
let(:procedure) { '' }
|
||||||
|
it { is_expected.to have_http_status(404) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
context 'when user is not logged' do
|
||||||
|
it { expect(response).to have_http_status(302) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,7 +15,15 @@ describe Users::SiretController, type: :controller do
|
||||||
sign_in create(:user)
|
sign_in create(:user)
|
||||||
end
|
end
|
||||||
subject { get :index, procedure_id: procedure }
|
subject { get :index, procedure_id: procedure }
|
||||||
it { expect(subject).to have_http_status(:success) }
|
|
||||||
|
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
|
context 'when procedure_id is not valid' do
|
||||||
let(:procedure) { '' }
|
let(:procedure) { '' }
|
||||||
it { is_expected.to have_http_status(404) }
|
it { is_expected.to have_http_status(404) }
|
||||||
|
@ -31,52 +39,4 @@ describe Users::SiretController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# describe 'GET #index with bad SIRET' do
|
|
||||||
# before do
|
|
||||||
# get :error_siret, procedure_id: procedure
|
|
||||||
# end
|
|
||||||
|
|
||||||
# it 'returns http success and flash alert is present' do
|
|
||||||
# expect(response).to have_http_status(:success)
|
|
||||||
# end
|
|
||||||
# it 'la flash alert est présente' do
|
|
||||||
# expect(flash[:alert]).to be_present
|
|
||||||
# end
|
|
||||||
# it 'la flash alert a un libellé correct' do
|
|
||||||
# expect(flash[:alert]).to have_content('Ce SIRET n\'est pas valide')
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# describe 'GET #index with bad LOGIN' do
|
|
||||||
# before do
|
|
||||||
# get :error_login
|
|
||||||
# end
|
|
||||||
|
|
||||||
# it 'returns http success and flash alert is present' do
|
|
||||||
# expect(response).to have_http_status(:success)
|
|
||||||
# end
|
|
||||||
# it 'la flash alert est présente' do
|
|
||||||
# expect(flash[:alert]).to be_present
|
|
||||||
# end
|
|
||||||
# it 'la flash alert a un libellé correct' do
|
|
||||||
# expect(flash[:alert]).to have_content('Ce compte n\'existe pas')
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
# describe 'GET #index with bad DOSSIER' do
|
|
||||||
# before do
|
|
||||||
# get :error_dossier
|
|
||||||
# end
|
|
||||||
|
|
||||||
# it 'returns http success and flash alert is present' do
|
|
||||||
# expect(response).to have_http_status(:success)
|
|
||||||
# end
|
|
||||||
# it 'la flash alert est présente' do
|
|
||||||
# expect(flash[:alert]).to be_present
|
|
||||||
# end
|
|
||||||
# it 'la flash alert a un libellé correct' do
|
|
||||||
# expect(flash[:alert]).to have_content('Ce dossier n\'existe pas')
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue