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.
This commit is contained in:
Javi Martín
2021-09-15 18:31:15 +02:00
parent 1e305440f8
commit d40535aaee
2 changed files with 6 additions and 1 deletions

View File

@@ -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

View File

@@ -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