Merge pull request #54 from sgmap/wording

Wording
This commit is contained in:
Mathieu Magnin 2017-04-03 16:07:50 +02:00 committed by GitHub
commit e0e452b70f
6 changed files with 53 additions and 18 deletions

View file

@ -122,7 +122,7 @@ class Users::DossiersController < UsersController
@facade = facade params[:dossier][:id]
if checked_autorisation_donnees?
unless Dossier.find(@facade.dossier.id).update_attributes update_params
unless Dossier.find(@facade.dossier.id).update_attributes update_params_with_formatted_birthdate
flash.alert = @facade.dossier.errors.full_messages.join('<br />').html_safe
return redirect_to users_dossier_path(id: @facade.dossier.id)
@ -171,6 +171,25 @@ class Users::DossiersController < UsersController
params.require(:dossier).permit(:id, :autorisation_donnees, individual_attributes: [:gender, :nom, :prenom, :birthdate])
end
def update_params_with_formatted_birthdate
editable_params = update_params
# If the user was shown a date input field (if its browser supports it),
# the returned param will follow the YYYY-MM-DD pattern, which we need
# do convert to the DD/MM/YYYY pattern we use
if editable_params &&
editable_params[:individual_attributes] &&
editable_params[:individual_attributes][:birthdate] &&
editable_params[:individual_attributes][:birthdate] =~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/
original_birthdate = editable_params[:individual_attributes][:birthdate]
formatted_birthdate = I18n.l(original_birthdate.to_date, format: '%d/%m/%Y')
editable_params[:individual_attributes][:birthdate] = formatted_birthdate
end
editable_params
end
def checked_autorisation_donnees?
update_params[:autorisation_donnees] == '1'
end

View file

@ -85,7 +85,7 @@
%h4 Options avancées
%label{ for: :auto_archive_on} Archivage automatique le
= f.text_field :auto_archive_on, id: 'auto_archive_on', value: @procedure.auto_archive_on.try{ |d| d.strftime("%d-%m-%Y") }, data: { provide: 'datepicker', 'date-format' => 'dd/mm/yyyy' }
= f.text_field :auto_archive_on, id: 'auto_archive_on', value: @procedure.auto_archive_on.try{ |d| d.strftime("%d-%m-%Y") }, data: { provide: 'datepicker', 'date-language' => 'fr', 'date-format' => 'dd/mm/yyyy' }
(à 00h00)
%p.help-block
%i.fa.fa-info-circle

View file

@ -31,7 +31,7 @@
%label
%h4
Date de naissance *
= ff.text_field :birthdate, {class: 'form-control', 'data-provide' => 'datepicker', 'data-date-format' => 'dd/mm/yyyy'}
= ff.date_field :birthdate, {class: 'form-control', placeholder: 'jj/mm/aaaa'}
%p
%label{ style:'font-weight:normal' }

View file

@ -85,7 +85,6 @@ set :shared_paths, [
"config/initializers/super_admin.rb",
"config/unicorn.rb",
"config/initializers/raven.rb",
"config/locales/dynamics/fr.yml",
'config/france_connect.yml',
'config/initializers/mailjet.rb',
'config/initializers/storage_url.rb',

View file

@ -1,6 +1,6 @@
fr:
dynamics:
page_title: TPS - Téléprocédures simplifiées
page_title: 'TPS - Téléprocédures simplifiées'
contact_email: contact@tps.apientreprise.fr
users:
connexion_title: Connexion

View file

@ -9,19 +9,36 @@ feature 'As a User I wanna create a dossier' do
let(:procedure_with_siret) { create(:procedure, :published, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
let(:procedure_for_individual) { create(:procedure, :published, :for_individual, :with_api_carto, :with_type_de_champ, :with_two_type_de_piece_justificative) }
scenario 'Identification for individual' do
login_as user, scope: :user
visit commencer_path(procedure_path: procedure_for_individual.path)
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
page.find_by_id('etape_suivante').click
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
page.find_by_id('etape_suivante').click
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
page.find_by_id('suivant').click
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
context 'Identification for individual' do
before do
login_as user, scope: :user
visit commencer_path(procedure_path: procedure_for_individual.path)
fill_in 'dossier_individual_attributes_nom', with: 'Nom'
fill_in 'dossier_individual_attributes_prenom', with: 'Prenom'
find(:css, "#dossier_autorisation_donnees[value='1']").set(true)
end
scenario "with a proper date input field for birthdate (type='date' supported)" do
fill_in 'dossier_individual_attributes_birthdate', with: '1987-10-14'
page.find_by_id('etape_suivante').click
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
page.find_by_id('etape_suivante').click
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
page.find_by_id('suivant').click
expect(user.dossiers.first.individual.birthdate).to eq("14/10/1987")
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
end
scenario "with a basic text input field for birthdate (type='date' unsupported)" do
fill_in 'dossier_individual_attributes_birthdate', with: '14/10/1987'
page.find_by_id('etape_suivante').click
expect(page).to have_current_path(users_dossier_carte_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
page.find_by_id('etape_suivante').click
fill_in "champs_#{procedure_for_individual.dossiers.last.champs.first.id}", with: 'contenu du champ 1'
page.find_by_id('suivant').click
expect(user.dossiers.first.individual.birthdate).to eq("14/10/1987")
expect(page).to have_current_path(users_dossier_recapitulatif_path(procedure_for_individual.dossiers.last.id.to_s), only_path: true)
end
end
scenario 'Identification through siret', vcr: {cassette_name: 'search_ban_paris'}, js: true do