parent
651f459dcc
commit
941c529b2c
15 changed files with 17 additions and 119 deletions
|
@ -1,27 +1,4 @@
|
||||||
$(document)
|
$(document).on('turbolinks:load', handle_siret_form_errors);
|
||||||
.on('turbolinks:load', the_terms)
|
|
||||||
.on('turbolinks:load', handle_siret_form_errors);
|
|
||||||
|
|
||||||
function the_terms() {
|
|
||||||
var the_terms = $("#dossier_autorisation_donnees");
|
|
||||||
|
|
||||||
if (the_terms.length == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
check_value(the_terms);
|
|
||||||
|
|
||||||
the_terms.click(function () {
|
|
||||||
check_value(the_terms);
|
|
||||||
});
|
|
||||||
|
|
||||||
function check_value(the_terms) {
|
|
||||||
if (the_terms.is(":checked")) {
|
|
||||||
$("#etape_suivante").removeAttr("disabled");
|
|
||||||
} else {
|
|
||||||
$("#etape_suivante").attr("disabled", "disabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function error_form_siret(invalid_siret) {
|
function error_form_siret(invalid_siret) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
|
|
@ -54,10 +54,8 @@ module NewUser
|
||||||
def update_identite
|
def update_identite
|
||||||
@dossier = dossier
|
@dossier = dossier
|
||||||
|
|
||||||
individual_updated = @dossier.individual.update(individual_params)
|
if @dossier.individual.update(individual_params)
|
||||||
dossier_updated = @dossier.update(dossier_params)
|
@dossier.update!(autorisation_donnees: true)
|
||||||
|
|
||||||
if individual_updated && dossier_updated
|
|
||||||
flash.notice = "Identité enregistrée"
|
flash.notice = "Identité enregistrée"
|
||||||
|
|
||||||
if @dossier.procedure.module_api_carto.use_api_carto
|
if @dossier.procedure.module_api_carto.use_api_carto
|
||||||
|
@ -66,7 +64,7 @@ module NewUser
|
||||||
redirect_to brouillon_dossier_path(@dossier)
|
redirect_to brouillon_dossier_path(@dossier)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
flash.now.alert = @dossier.errors.full_messages
|
flash.now.alert = @dossier.individual.errors.full_messages
|
||||||
render :identite
|
render :identite
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -257,10 +255,6 @@ module NewUser
|
||||||
params.require(:individual).permit(:gender, :nom, :prenom, :birthdate)
|
params.require(:individual).permit(:gender, :nom, :prenom, :birthdate)
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_params
|
|
||||||
params.require(:dossier).permit(:autorisation_donnees)
|
|
||||||
end
|
|
||||||
|
|
||||||
def commentaire_params
|
def commentaire_params
|
||||||
params.require(:commentaire).permit(:body, :file)
|
params.require(:commentaire).permit(:body, :file)
|
||||||
end
|
end
|
||||||
|
|
|
@ -132,16 +132,7 @@ class Users::DossiersController < UsersController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@facade = facade params[:dossier][:id]
|
@facade = facade params[:dossier][:id]
|
||||||
|
@facade.dossier.update!(autorisation_donnees: true)
|
||||||
if individual_errors.any?
|
|
||||||
flash.alert = individual_errors
|
|
||||||
redirect_to users_dossier_path(id: @facade.dossier.id)
|
|
||||||
else
|
|
||||||
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)
|
|
||||||
end
|
|
||||||
|
|
||||||
if @facade.dossier.procedure.module_api_carto.use_api_carto
|
if @facade.dossier.procedure.module_api_carto.use_api_carto
|
||||||
redirect_to url_for(controller: :carte, action: :show, dossier_id: @facade.dossier.id)
|
redirect_to url_for(controller: :carte, action: :show, dossier_id: @facade.dossier.id)
|
||||||
|
@ -149,7 +140,6 @@ class Users::DossiersController < UsersController
|
||||||
redirect_to brouillon_dossier_path(@facade.dossier)
|
redirect_to brouillon_dossier_path(@facade.dossier)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def self.route_authorization
|
def self.route_authorization
|
||||||
{
|
{
|
||||||
|
@ -181,20 +171,6 @@ class Users::DossiersController < UsersController
|
||||||
render '/dossiers/new_siret', formats: :js, locals: { invalid_siret: siret }
|
render '/dossiers/new_siret', formats: :js, locals: { invalid_siret: siret }
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_params
|
|
||||||
params.require(:dossier).permit(:id, :autorisation_donnees)
|
|
||||||
end
|
|
||||||
|
|
||||||
def individual_errors
|
|
||||||
errors = []
|
|
||||||
|
|
||||||
if update_params[:autorisation_donnees] != "1"
|
|
||||||
errors << "La validation des conditions d'utilisation est obligatoire"
|
|
||||||
end
|
|
||||||
|
|
||||||
errors
|
|
||||||
end
|
|
||||||
|
|
||||||
def siret
|
def siret
|
||||||
create_params[:siret]
|
create_params[:siret]
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,8 +36,6 @@ class Dossier < ApplicationRecord
|
||||||
accepts_nested_attributes_for :champs
|
accepts_nested_attributes_for :champs
|
||||||
accepts_nested_attributes_for :champs_private
|
accepts_nested_attributes_for :champs_private
|
||||||
|
|
||||||
validates :autorisation_donnees, acceptance: { message: 'doit être coché' }, allow_nil: false, on: :update
|
|
||||||
|
|
||||||
default_scope { where(hidden_at: nil) }
|
default_scope { where(hidden_at: nil) }
|
||||||
scope :state_brouillon, -> { where(state: states.fetch(:brouillon)) }
|
scope :state_brouillon, -> { where(state: states.fetch(:brouillon)) }
|
||||||
scope :state_not_brouillon, -> { where.not(state: states.fetch(:brouillon)) }
|
scope :state_not_brouillon, -> { where.not(state: states.fetch(:brouillon)) }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<% if flash.empty? %>
|
<% if flash.empty? %>
|
||||||
$('.row.etape.etape-2').hide(300, render_new_siret);
|
$('.row.etape.etape-2').hide(300, render_new_siret);
|
||||||
$('.row.etape.etape-2').slideDown(400, the_terms);
|
$('.row.etape.etape-2').slideDown(400);
|
||||||
<% else %>
|
<% else %>
|
||||||
error_form_siret('<%= invalid_siret %>');
|
error_form_siret('<%= invalid_siret %>');
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -33,8 +33,4 @@
|
||||||
%br
|
%br
|
||||||
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
|
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
|
||||||
= f.hidden_field :id
|
= f.hidden_field :id
|
||||||
%label{ style: 'font-weight: normal;' }
|
= f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float: right;', id: 'etape_suivante'
|
||||||
= f.check_box :autorisation_donnees
|
|
||||||
J'autorise les décideurs publics à vérifier les informations de mon organisation auprès des administrations concernées. Ces informations resteront strictement confidentielles.
|
|
||||||
%br
|
|
||||||
= f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float: right;', id: 'etape_suivante', disabled: :disabled
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<% if flash.empty? %>
|
<% if flash.empty? %>
|
||||||
$('.row.etape.etape-2').hide(300, render_new_siret);
|
$('.row.etape.etape-2').hide(300, render_new_siret);
|
||||||
$('.row.etape.etape-2').slideDown(400, the_terms);
|
$('.row.etape.etape-2').slideDown(400);
|
||||||
toggle_etape_1();
|
toggle_etape_1();
|
||||||
<% else %>
|
<% else %>
|
||||||
error_form_siret('<%= invalid_siret %>');
|
error_form_siret('<%= invalid_siret %>');
|
||||||
|
|
|
@ -44,11 +44,4 @@
|
||||||
= f.label :birthdate, class: "required"
|
= f.label :birthdate, class: "required"
|
||||||
= f.date_field :birthdate, value: @dossier.individual.birthdate, placeholder: 'format : AAAA-MM-JJ', required: true, class: "small"
|
= f.date_field :birthdate, value: @dossier.individual.birthdate, placeholder: 'format : AAAA-MM-JJ', required: true, class: "small"
|
||||||
|
|
||||||
= fields_for :dossier, @dossier do |df|
|
|
||||||
= label_tag do
|
|
||||||
= df.check_box :autorisation_donnees, required: true
|
|
||||||
J'accepte
|
|
||||||
= link_to "les CGU", CGU_URL, target: :blank
|
|
||||||
%span.mandatory *
|
|
||||||
|
|
||||||
= f.submit "Continuer", class: "button large primary expand"
|
= f.submit "Continuer", class: "button large primary expand"
|
||||||
|
|
|
@ -162,7 +162,7 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
let(:procedure) { create(:procedure, :for_individual) }
|
let(:procedure) { create(:procedure, :for_individual) }
|
||||||
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
|
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
|
||||||
|
|
||||||
subject { post :update_identite, params: { id: dossier.id, individual: individual_params, dossier: dossier_params } }
|
subject { post :update_identite, params: { id: dossier.id, individual: individual_params } }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
@ -171,7 +171,6 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
|
|
||||||
context 'with correct individual and dossier params' do
|
context 'with correct individual and dossier params' do
|
||||||
let(:individual_params) { { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } }
|
let(:individual_params) { { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } }
|
||||||
let(:dossier_params) { { autorisation_donnees: true } }
|
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(response).to redirect_to(brouillon_dossier_path(dossier))
|
expect(response).to redirect_to(brouillon_dossier_path(dossier))
|
||||||
|
@ -189,7 +188,6 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
context 'when the identite cannot be updated by the user' do
|
context 'when the identite cannot be updated by the user' do
|
||||||
let(:dossier) { create(:dossier, :for_individual, :en_instruction, user: user, procedure: procedure) }
|
let(:dossier) { create(:dossier, :for_individual, :en_instruction, user: user, procedure: procedure) }
|
||||||
let(:individual_params) { { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } }
|
let(:individual_params) { { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } }
|
||||||
let(:dossier_params) { { autorisation_donnees: true } }
|
|
||||||
|
|
||||||
it 'redirects to the dossiers list' do
|
it 'redirects to the dossiers list' do
|
||||||
expect(response).to redirect_to(dossiers_path)
|
expect(response).to redirect_to(dossiers_path)
|
||||||
|
@ -199,11 +197,10 @@ describe NewUser::DossiersController, type: :controller do
|
||||||
|
|
||||||
context 'with incorrect individual and dossier params' do
|
context 'with incorrect individual and dossier params' do
|
||||||
let(:individual_params) { { gender: '', nom: '', prenom: '' } }
|
let(:individual_params) { { gender: '', nom: '', prenom: '' } }
|
||||||
let(:dossier_params) { { autorisation_donnees: nil } }
|
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(response).not_to have_http_status(:redirect)
|
expect(response).not_to have_http_status(:redirect)
|
||||||
expect(flash[:alert]).to include("Civilité doit être rempli", "Nom doit être rempli", "Prénom doit être rempli", "Acceptation des CGU doit être coché")
|
expect(flash[:alert]).to include("Civilité doit être rempli", "Nom doit être rempli", "Prénom doit être rempli")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -338,7 +338,7 @@ describe Users::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'PUT #update' do
|
describe 'PUT #update' do
|
||||||
let(:params) { { id: dossier_id, dossier: { id: dossier_id, autorisation_donnees: autorisation_donnees, individual_attributes: individual_params } } }
|
let(:params) { { id: dossier_id, dossier: { id: dossier_id, individual_attributes: individual_params } } }
|
||||||
let(:individual_params) { { gender: 'M.', nom: 'Julien', prenom: 'Xavier', birthdate: birthdate } }
|
let(:individual_params) { { gender: 'M.', nom: 'Julien', prenom: 'Xavier', birthdate: birthdate } }
|
||||||
let(:birthdate) { '20/01/1991' }
|
let(:birthdate) { '20/01/1991' }
|
||||||
subject { put :update, params: params }
|
subject { put :update, params: params }
|
||||||
|
@ -351,8 +351,6 @@ describe Users::DossiersController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when Checkbox is checked' do
|
context 'when Checkbox is checked' do
|
||||||
let(:autorisation_donnees) { '1' }
|
|
||||||
|
|
||||||
context 'procedure not use api carto' do
|
context 'procedure not use api carto' do
|
||||||
it 'redirects to demande' do
|
it 'redirects to demande' do
|
||||||
expect(response).to redirect_to(brouillon_dossier_path(dossier))
|
expect(response).to redirect_to(brouillon_dossier_path(dossier))
|
||||||
|
@ -375,20 +373,6 @@ describe Users::DossiersController, type: :controller do
|
||||||
expect(dossier.autorisation_donnees).to be_truthy
|
expect(dossier.autorisation_donnees).to be_truthy
|
||||||
end
|
end
|
||||||
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('La validation des conditions d\'utilisation est obligatoire')
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't update dossier autorisation_donnees" do
|
|
||||||
dossier.reload
|
|
||||||
expect(dossier.autorisation_donnees).to be_falsy
|
|
||||||
end
|
|
||||||
|
|
||||||
it { is_expected.to redirect_to users_dossier_path(id: dossier.id) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'DELETE #destroy' do
|
describe 'DELETE #destroy' do
|
||||||
|
|
|
@ -150,7 +150,6 @@ feature 'The user' do
|
||||||
def fill_individual
|
def fill_individual
|
||||||
fill_in('individual_prenom', with: 'prenom')
|
fill_in('individual_prenom', with: 'prenom')
|
||||||
fill_in('individual_nom', with: 'nom')
|
fill_in('individual_nom', with: 'nom')
|
||||||
check 'dossier_autorisation_donnees'
|
|
||||||
click_on 'Continuer'
|
click_on 'Continuer'
|
||||||
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,7 +59,6 @@ feature 'linked dropdown lists' do
|
||||||
def fill_individual
|
def fill_individual
|
||||||
fill_in('individual_prenom', with: 'prenom')
|
fill_in('individual_prenom', with: 'prenom')
|
||||||
fill_in('individual_nom', with: 'nom')
|
fill_in('individual_nom', with: 'nom')
|
||||||
check 'dossier_autorisation_donnees'
|
|
||||||
click_on 'Continuer'
|
click_on 'Continuer'
|
||||||
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,7 +60,6 @@ feature 'user path for dossier creation' do
|
||||||
|
|
||||||
context 'when validating info entreprise recap page' do
|
context 'when validating info entreprise recap page' do
|
||||||
before do
|
before do
|
||||||
page.check('dossier_autorisation_donnees')
|
|
||||||
page.find_by_id('etape_suivante').click
|
page.find_by_id('etape_suivante').click
|
||||||
end
|
end
|
||||||
scenario 'user is on edition page' do
|
scenario 'user is on edition page' do
|
||||||
|
|
|
@ -15,7 +15,6 @@ feature 'As a User I wanna create a dossier' do
|
||||||
visit commencer_path(procedure_path: procedure_for_individual.path)
|
visit commencer_path(procedure_path: procedure_for_individual.path)
|
||||||
fill_in 'individual_nom', with: 'Nom'
|
fill_in 'individual_nom', with: 'Nom'
|
||||||
fill_in 'individual_prenom', with: 'Prenom'
|
fill_in 'individual_prenom', with: 'Prenom'
|
||||||
check "dossier_autorisation_donnees"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when birthday is asked" do
|
context "when birthday is asked" do
|
||||||
|
@ -77,14 +76,13 @@ feature 'As a User I wanna create a dossier' do
|
||||||
.to_return(status: 404, body: '')
|
.to_return(status: 404, body: '')
|
||||||
|
|
||||||
page.find_by_id('dossier-siret').set siret
|
page.find_by_id('dossier-siret').set siret
|
||||||
page.find_by_id('submit-siret').click
|
click_on 'Valider'
|
||||||
wait_for_ajax
|
wait_for_ajax
|
||||||
|
|
||||||
expect(page).to have_css('#recap-info-entreprise')
|
expect(page).to have_css('#recap-info-entreprise')
|
||||||
check 'dossier_autorisation_donnees'
|
click_on 'Etape suivante'
|
||||||
page.find_by_id('etape_suivante').click
|
|
||||||
expect(page).to have_current_path(users_dossier_carte_path(procedure_with_siret.dossiers.last.id.to_s))
|
expect(page).to have_current_path(users_dossier_carte_path(procedure_with_siret.dossiers.last.id.to_s))
|
||||||
page.find_by_id('etape_suivante').click
|
click_on 'Etape suivante'
|
||||||
expect(page).to have_current_path(brouillon_dossier_path(procedure_with_siret.dossiers.last))
|
expect(page).to have_current_path(brouillon_dossier_path(procedure_with_siret.dossiers.last))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,23 +10,11 @@ describe 'dossiers/show.html.haml', type: :view do
|
||||||
render
|
render
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'have autorisation_donnees check box' do
|
|
||||||
expect(rendered).to have_css('#dossier_autorisation_donnees')
|
|
||||||
end
|
|
||||||
|
|
||||||
context "sur la page d'information d'un SIRET" do
|
context "sur la page d'information d'un SIRET" do
|
||||||
it 'Le formulaire envoie vers /users/dossiers/:dossier_id en #POST' do
|
it 'Le formulaire envoie vers /users/dossiers/:dossier_id en #POST' do
|
||||||
expect(rendered).to have_selector("form[action='/users/dossiers'][method=post]")
|
expect(rendered).to have_selector("form[action='/users/dossiers'][method=post]")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "la checkbox d'information est présente" do
|
|
||||||
expect(rendered).to have_css('#dossier_autorisation_donnees')
|
|
||||||
end
|
|
||||||
|
|
||||||
it "le texte d'information des droits est correct" do
|
|
||||||
expect(rendered).to have_content("J'autorise les décideurs publics à vérifier les informations de mon organisation auprès des administrations concernées. Ces informations resteront strictement confidentielles.")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "les informations de l'entreprise sont présents" do
|
it "les informations de l'entreprise sont présents" do
|
||||||
expect(rendered).to have_content('Siret')
|
expect(rendered).to have_content('Siret')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue