From c22e800329d4f690e2380d57671c31cfe8b835eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 12 Jul 2020 23:44:31 +0200 Subject: [PATCH] Remove code duplication We were calling the same method three times. --- app/views/budgets/ballot/_ballot.html.erb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/budgets/ballot/_ballot.html.erb b/app/views/budgets/ballot/_ballot.html.erb index cd70aea12..795246d47 100644 --- a/app/views/budgets/ballot/_ballot.html.erb +++ b/app/views/budgets/ballot/_ballot.html.erb @@ -19,21 +19,22 @@
<% ballot_groups = @ballot.groups.sort_by_name %> <% ballot_groups.each do |group| %> + <% heading = @ballot.heading_for_group(group) %>

- <%= group.name %> - <%= @ballot.heading_for_group(group).name %> + <%= group.name %> - <%= heading.name %>

<%= link_to sanitize(t("budgets.ballots.show.remaining", - amount: @ballot.formatted_amount_available(@ballot.heading_for_group(group)))), + amount: @ballot.formatted_amount_available(heading))), budget_group_path(@budget, group) %>
<% if @ballot.has_lines_in_group?(group) %>

<%= t("budgets.ballots.show.amount_spent") %> - <%= @ballot.formatted_amount_spent(@ballot.heading_for_group(group)) %> + <%= @ballot.formatted_amount_spent(heading) %>

<% else %>