From d40535aaeece4da4080c3e3597fe436a2e281842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 15 Sep 2021 18:31:15 +0200 Subject: [PATCH] Fix help text in wizard with validation errors There was an edge case where we could access the headings index without sending the mode parameter in the URL. That meant when sending the headings form we could send a form with the mode hidden field set to an empty string. When that happened, the returned text was `t("admin.budgets.help.#{i18n_namespace}.`, which returned a hash. Using `multiple` when an empty strin is received solves the issue. --- app/components/admin/budgets/help_component.rb | 2 +- spec/system/admin/budgets_wizard/headings_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/components/admin/budgets/help_component.rb b/app/components/admin/budgets/help_component.rb index bd47604d4..b99f91a2c 100644 --- a/app/components/admin/budgets/help_component.rb +++ b/app/components/admin/budgets/help_component.rb @@ -6,7 +6,7 @@ class Admin::Budgets::HelpComponent < ApplicationComponent end def budget_mode - (helpers.budget_mode if helpers.respond_to?(:budget_mode)) || "multiple" + (helpers.budget_mode if helpers.respond_to?(:budget_mode)).presence || "multiple" end private diff --git a/spec/system/admin/budgets_wizard/headings_spec.rb b/spec/system/admin/budgets_wizard/headings_spec.rb index 0a093ed8f..28d6c1657 100644 --- a/spec/system/admin/budgets_wizard/headings_spec.rb +++ b/spec/system/admin/budgets_wizard/headings_spec.rb @@ -81,6 +81,11 @@ describe "Budgets wizard, headings step", :admin do expect(page).to have_button "Cancel" expect(page).not_to have_button "Add new heading" expect(page).not_to have_content "Continue to phases" + + within ".budgets-help" do + expect(page).to have_content "Headings are meant" + expect(page).not_to have_content "{" + end end end