Skip to content

Commit

Permalink
Remove system count from old booth assigments
Browse files Browse the repository at this point in the history
This number was not the important one; the important one is the one
given by the recounts.

Note we're also removing the votes by date, since they're also system
votes.
  • Loading branch information
javierm committed Jun 11, 2019
1 parent 01265c6 commit a71f96a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 20 deletions.
48 changes: 28 additions & 20 deletions app/views/admin/poll/booth_assignments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,46 @@
<thead>
<tr>
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_final") %></th>
<th class="text-center"><%= t("admin.poll_booth_assignments.show.total_system") %></th>

<% unless @poll.recounts_confirmed? %>
<th class="text-center"><%= t("admin.poll_booth_assignments.show.total_system") %></th>
<% end %>
</tr>
</thead>
<tbody>
<tr>
<td class="text-center" id="total_final">
<%= total_recounts_by_booth(@booth_assignment) || "-" %>
</td>
<td class="text-center" id="total_system">
<%= @booth_assignment.voters.count %>
</td>

<% unless @poll.recounts_confirmed? %>
<td class="text-center" id="total_system">
<%= @booth_assignment.voters.count %>
</td>
<% end %>
</tr>
</tbody>
</table>

<table id="recounts_list">
<thead>
<tr>
<th><%= t("admin.poll_booth_assignments.show.date") %></th>
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_by_system") %></th>
</tr>
</thead>
<tbody>
<% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %>
<% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %>
<tr id="recounting_<%= voting_date.strftime("%Y%m%d") %>">
<td><%= l voting_date %></td>
<td class="text-center"><%= system_count %></td>
<% unless @poll.recounts_confirmed? %>
<table id="recounts_list">
<thead>
<tr>
<th><%= t("admin.poll_booth_assignments.show.date") %></th>
<th class="text-center"><%= t("admin.poll_booth_assignments.show.count_by_system") %></th>
</tr>
<% end %>
</tbody>
</table>
</thead>
<tbody>
<% (@poll.starts_at.to_date..@poll.ends_at.to_date).each do |voting_date| %>
<% system_count = @voters_by_date[voting_date].present? ? @voters_by_date[voting_date].size : 0 %>
<tr id="recounting_<%= voting_date.strftime("%Y%m%d") %>">
<td><%= l voting_date %></td>
<td class="text-center"><%= system_count %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
<div class="tabs-panel is-active" id="tab-results">
<%= render "results" %>
Expand Down
20 changes: 20 additions & 0 deletions spec/features/admin/poll/booth_assigments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,26 @@
end
end

scenario "Doesn't show system recounts for old polls" do
poll = create(:poll, :old)
booth_assignment = create(:poll_booth_assignment, poll: poll)

create(:poll_voter, poll: poll, booth_assignment: booth_assignment)
create(:poll_recount, booth_assignment: booth_assignment, total_amount: 10)

visit admin_poll_booth_assignment_path(poll, booth_assignment)

within("#totals") do
within("#total_final") do
expect(page).to have_content "10"
end

expect(page).not_to have_selector "#total_system"
end

expect(page).not_to have_selector "#recounts_list"
end

scenario "Results for a booth assignment" do
poll = create(:poll)
booth_assignment = create(:poll_booth_assignment, poll: poll)
Expand Down

0 comments on commit a71f96a

Please sign in to comment.