From 9616df192d21f558c20ba71c30b60f0b61fc56c8 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 10 Jul 2019 18:47:08 +0200 Subject: [PATCH 1/2] procedure: use the model value for checking the radio buttons Previously `checked: true` forced the checked status, disregarding the actual value of the model. Fix #4080 --- app/views/admin/procedures/_informations.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/procedures/_informations.html.haml b/app/views/admin/procedures/_informations.html.haml index 33ba974e9..7c1b8ad31 100644 --- a/app/views/admin/procedures/_informations.html.haml +++ b/app/views/admin/procedures/_informations.html.haml @@ -100,7 +100,7 @@ %h4 À qui s’adresse ma démarche ? .checkbox %label - = f.radio_button :for_individual, 1, :checked => true + = f.radio_button :for_individual, true %b Ma démarche s’adresse à un particulier %p @@ -108,7 +108,7 @@ .checkbox %label - = f.radio_button :for_individual, 0, :checked => false + = f.radio_button :for_individual, false %b Ma démarche s’adresse à une personne morale %p From 7ca3d5fce2e28d73f1b4c4d3cc322e907fde905e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 10 Jul 2019 18:47:19 +0200 Subject: [PATCH 2/2] procedure: select `for_individual` by default --- app/controllers/admin/procedures_controller.rb | 2 +- spec/features/admin/procedure_creation_spec.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/procedures_controller.rb b/app/controllers/admin/procedures_controller.rb index ae22689a5..749916a48 100644 --- a/app/controllers/admin/procedures_controller.rb +++ b/app/controllers/admin/procedures_controller.rb @@ -62,7 +62,7 @@ class Admin::ProceduresController < AdminController end def new - @procedure ||= Procedure.new + @procedure ||= Procedure.new(for_individual: true) @availability = Procedure::PATH_AVAILABLE end diff --git a/spec/features/admin/procedure_creation_spec.rb b/spec/features/admin/procedure_creation_spec.rb index 78bfb5c15..8ff486f90 100644 --- a/spec/features/admin/procedure_creation_spec.rb +++ b/spec/features/admin/procedure_creation_spec.rb @@ -36,6 +36,8 @@ feature 'As an administrateur I wanna create a new procedure', js: true do click_on 'from-scratch' expect(page).to have_current_path(new_admin_procedure_path) + expect(find('#procedure_for_individual_true')).to be_checked + expect(find('#procedure_for_individual_false')).not_to be_checked fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3' fill_in 'procedure_duree_conservation_dossiers_hors_ds', with: '6' click_on 'save-procedure'