Merge pull request #2731 from tchak/remove-cgu-checkbox

Remove CGU checkbox
This commit is contained in:
Pierre de La Morinerie 2018-10-03 09:19:20 +02:00 committed by GitHub
commit 21d1788018
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 17 additions and 119 deletions

View file

@ -1,27 +1,4 @@
$(document)
.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");
}
}
}
$(document).on('turbolinks:load', handle_siret_form_errors);
function error_form_siret(invalid_siret) {
setTimeout(function () {

View file

@ -54,10 +54,8 @@ module NewUser
def update_identite
@dossier = dossier
individual_updated = @dossier.individual.update(individual_params)
dossier_updated = @dossier.update(dossier_params)
if individual_updated && dossier_updated
if @dossier.individual.update(individual_params)
@dossier.update!(autorisation_donnees: true)
flash.notice = "Identité enregistrée"
if @dossier.procedure.module_api_carto.use_api_carto
@ -66,7 +64,7 @@ module NewUser
redirect_to brouillon_dossier_path(@dossier)
end
else
flash.now.alert = @dossier.errors.full_messages
flash.now.alert = @dossier.individual.errors.full_messages
render :identite
end
end
@ -257,10 +255,6 @@ module NewUser
params.require(:individual).permit(:gender, :nom, :prenom, :birthdate)
end
def dossier_params
params.require(:dossier).permit(:autorisation_donnees)
end
def commentaire_params
params.require(:commentaire).permit(:body, :file)
end

View file

@ -132,22 +132,12 @@ class Users::DossiersController < UsersController
def update
@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)
if @facade.dossier.procedure.module_api_carto.use_api_carto
redirect_to url_for(controller: :carte, action: :show, dossier_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
redirect_to url_for(controller: :carte, action: :show, dossier_id: @facade.dossier.id)
else
redirect_to brouillon_dossier_path(@facade.dossier)
end
redirect_to brouillon_dossier_path(@facade.dossier)
end
end
@ -181,20 +171,6 @@ class Users::DossiersController < UsersController
render '/dossiers/new_siret', formats: :js, locals: { invalid_siret: siret }
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
create_params[:siret]
end

View file

@ -36,8 +36,6 @@ class Dossier < ApplicationRecord
accepts_nested_attributes_for :champs
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) }
scope :state_brouillon, -> { where(state: states.fetch(:brouillon)) }
scope :state_not_brouillon, -> { where.not(state: states.fetch(:brouillon)) }

View file

@ -1,6 +1,6 @@
<% if flash.empty? %>
$('.row.etape.etape-2').hide(300, render_new_siret);
$('.row.etape.etape-2').slideDown(400, the_terms);
$('.row.etape.etape-2').slideDown(400);
<% else %>
error_form_siret('<%= invalid_siret %>');
<% end %>

View file

@ -33,8 +33,4 @@
%br
= form_for @facade.dossier, url: { controller: '/users/dossiers', action: :update } do |f|
= f.hidden_field :id
%label{ style: 'font-weight: normal;' }
= 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
= f.submit 'Etape suivante', class: "btn btn btn-info", style: 'float: right;', id: 'etape_suivante'

View file

@ -1,6 +1,6 @@
<% if flash.empty? %>
$('.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();
<% else %>
error_form_siret('<%= invalid_siret %>');

View file

@ -44,11 +44,4 @@
= f.label :birthdate, class: "required"
= 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"

View file

@ -162,7 +162,7 @@ describe NewUser::DossiersController, type: :controller do
let(:procedure) { create(:procedure, :for_individual) }
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
sign_in(user)
@ -171,7 +171,6 @@ describe NewUser::DossiersController, type: :controller do
context 'with correct individual and dossier params' do
let(:individual_params) { { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } }
let(:dossier_params) { { autorisation_donnees: true } }
it do
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
let(:dossier) { create(:dossier, :for_individual, :en_instruction, user: user, procedure: procedure) }
let(:individual_params) { { gender: 'M', nom: 'Mouse', prenom: 'Mickey' } }
let(:dossier_params) { { autorisation_donnees: true } }
it 'redirects to the dossiers list' do
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
let(:individual_params) { { gender: '', nom: '', prenom: '' } }
let(:dossier_params) { { autorisation_donnees: nil } }
it do
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

View file

@ -338,7 +338,7 @@ describe Users::DossiersController, type: :controller do
end
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(:birthdate) { '20/01/1991' }
subject { put :update, params: params }
@ -351,8 +351,6 @@ describe Users::DossiersController, type: :controller do
end
context 'when Checkbox is checked' do
let(:autorisation_donnees) { '1' }
context 'procedure not use api carto' do
it 'redirects to demande' do
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
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
describe 'DELETE #destroy' do

View file

@ -150,7 +150,6 @@ feature 'The user' do
def fill_individual
fill_in('individual_prenom', with: 'prenom')
fill_in('individual_nom', with: 'nom')
check 'dossier_autorisation_donnees'
click_on 'Continuer'
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
end

View file

@ -59,7 +59,6 @@ feature 'linked dropdown lists' do
def fill_individual
fill_in('individual_prenom', with: 'prenom')
fill_in('individual_nom', with: 'nom')
check 'dossier_autorisation_donnees'
click_on 'Continuer'
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
end

View file

@ -60,7 +60,6 @@ feature 'user path for dossier creation' do
context 'when validating info entreprise recap page' do
before do
page.check('dossier_autorisation_donnees')
page.find_by_id('etape_suivante').click
end
scenario 'user is on edition page' do

View file

@ -15,7 +15,6 @@ feature 'As a User I wanna create a dossier' do
visit commencer_path(procedure_path: procedure_for_individual.path)
fill_in 'individual_nom', with: 'Nom'
fill_in 'individual_prenom', with: 'Prenom'
check "dossier_autorisation_donnees"
end
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: '')
page.find_by_id('dossier-siret').set siret
page.find_by_id('submit-siret').click
click_on 'Valider'
wait_for_ajax
expect(page).to have_css('#recap-info-entreprise')
check 'dossier_autorisation_donnees'
page.find_by_id('etape_suivante').click
click_on 'Etape suivante'
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))
end
end

View file

@ -10,23 +10,11 @@ describe 'dossiers/show.html.haml', type: :view do
render
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
it 'Le formulaire envoie vers /users/dossiers/:dossier_id en #POST' do
expect(rendered).to have_selector("form[action='/users/dossiers'][method=post]")
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
expect(rendered).to have_content('Siret')
end