From 2b90d7cc016ff3008c2349acfcc4c9683bb86f44 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 31 May 2022 08:44:40 +0200 Subject: [PATCH] helpers: allow champ without persisted dossier This fixes the /patron page. I also added an end-to-end test to avoid breaking this page in the future. --- app/helpers/champ_helper.rb | 2 +- spec/system/patron_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 spec/system/patron_spec.rb diff --git a/app/helpers/champ_helper.rb b/app/helpers/champ_helper.rb index d2fc3d4ee..aa8094207 100644 --- a/app/helpers/champ_helper.rb +++ b/app/helpers/champ_helper.rb @@ -28,7 +28,7 @@ module ChampHelper def autosave_available?(champ) # FIXME: enable autosave on champs private? once we figured out how to batch audit events - champ.dossier.brouillon? && !champ.repetition? + champ.dossier&.brouillon? && !champ.repetition? end def geo_area_label(geo_area) diff --git a/spec/system/patron_spec.rb b/spec/system/patron_spec.rb new file mode 100644 index 000000000..ba472ddfe --- /dev/null +++ b/spec/system/patron_spec.rb @@ -0,0 +1,8 @@ +describe 'Accessing the /patron page:' do + scenario 'I can display a page with all form fields and UI elements' do + visit patron_path + expect(page).to have_text('IcĂ´nes') + expect(page).to have_text('Formulaires') + expect(page).to have_text('Boutons') + end +end