From 2f100057392e7886a6ed0b782fc8f3631f5f3722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 8 Jul 2019 15:33:52 +0200 Subject: [PATCH] Fix text confirming investment heading support We accidentally removed the `count` option in commit 55fb14ac, which made the translation return a hash. The test is a bit hacky, which makes me think changing the user interface would probably be a better solution. --- app/views/budgets/investments/_votes.html.erb | 2 +- config/locales/en/budgets.yml | 2 +- spec/features/budgets/votes_spec.rb | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/budgets/investments/_votes.html.erb b/app/views/budgets/investments/_votes.html.erb index 040dd5e3e..0483e9040 100644 --- a/app/views/budgets/investments/_votes.html.erb +++ b/app/views/budgets/investments/_votes.html.erb @@ -20,7 +20,7 @@ method: "post", remote: (display_support_alert?(investment) ? false : true), data: (display_support_alert?(investment) ? { - confirm: t("budgets.investments.investment.confirm_group") } : nil), + confirm: t("budgets.investments.investment.confirm_group", count: investment.group.max_votable_headings) } : nil), "aria-hidden" => css_for_aria_hidden(reason) do %> <%= t("budgets.investments.investment.give_support") %> <% end %> diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml index c209d4d2c..f3b576ce3 100644 --- a/config/locales/en/budgets.yml +++ b/config/locales/en/budgets.yml @@ -137,7 +137,7 @@ en: support_title: Support this project confirm_group: one: "You can only support investments in %{count} district. If you continue you cannot change the election of your district. Are you sure?" - other: "You can only support investments in %{count} district. If you continue you cannot change the election of your district. Are you sure?" + other: "You can only support investments in %{count} districts. If you continue you cannot change the election of your district. Are you sure?" supports: one: 1 support other: "%{count} supports" diff --git a/spec/features/budgets/votes_spec.rb b/spec/features/budgets/votes_spec.rb index 6b079689f..826e8108c 100644 --- a/spec/features/budgets/votes_spec.rb +++ b/spec/features/budgets/votes_spec.rb @@ -191,6 +191,13 @@ describe "Votes" do "Share it!" end + scenario "Confirm message shows the right text", :js do + visit budget_investments_path(budget, heading_id: new_york.id) + find(".in-favor a").click + + expect(page.driver.send(:find_modal).text).to match "You can only support investments in 2 districts." + end + end end end