Remove system count column for old polls
System count isn't a relevant number because the important one is the number of votes counted by poll officers. We're still maintaining it for a month in case poll officers would like to review the results.
This commit is contained in:
@@ -81,6 +81,10 @@ class Poll < ApplicationRecord
|
|||||||
ends_at < timestamp
|
ends_at < timestamp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def recounts_confirmed?
|
||||||
|
ends_at < 1.month.ago
|
||||||
|
end
|
||||||
|
|
||||||
def self.current_or_recounting
|
def self.current_or_recounting
|
||||||
current + recounting
|
current + recounting
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,10 @@
|
|||||||
<% unless @poll.budget_poll? %>
|
<% unless @poll.budget_poll? %>
|
||||||
<th class="text-center"><%= t("admin.recounts.index.total_final") %></th>
|
<th class="text-center"><%= t("admin.recounts.index.total_final") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% unless @poll.recounts_confirmed? %>
|
||||||
<th class="text-center"><%= t("admin.recounts.index.total_system") %></th>
|
<th class="text-center"><%= t("admin.recounts.index.total_system") %></th>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -26,7 +29,10 @@
|
|||||||
<% unless @poll.budget_poll? %>
|
<% unless @poll.budget_poll? %>
|
||||||
<td class="text-center" id="total_final"><%= @stats.total_participants_booth %></td>
|
<td class="text-center" id="total_final"><%= @stats.total_participants_booth %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% unless @poll.recounts_confirmed? %>
|
||||||
<td class="text-center" id="total_system"><%= @stats.total_registered_booth %></td>
|
<td class="text-center" id="total_system"><%= @stats.total_registered_booth %></td>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -37,7 +43,10 @@
|
|||||||
<% unless @poll.budget_poll? %>
|
<% unless @poll.budget_poll? %>
|
||||||
<th class="text-center"><%= t("admin.recounts.index.table_total_recount") %></th>
|
<th class="text-center"><%= t("admin.recounts.index.table_total_recount") %></th>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% unless @poll.recounts_confirmed? %>
|
||||||
<th class="text-center"><%= t("admin.recounts.index.table_system_count") %></th>
|
<th class="text-center"><%= t("admin.recounts.index.table_system_count") %></th>
|
||||||
|
<% end %>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @booth_assignments.each do |booth_assignment| %>
|
<% @booth_assignments.each do |booth_assignment| %>
|
||||||
@@ -50,7 +59,7 @@
|
|||||||
</strong>
|
</strong>
|
||||||
</td>
|
</td>
|
||||||
<% unless @poll.budget_poll? %>
|
<% unless @poll.budget_poll? %>
|
||||||
<td class="text-center <%= "count-error" if total_recounts.to_i != system_count %>" id="<%= dom_id(booth_assignment) %>_recount">
|
<td class="text-center" id="<%= dom_id(booth_assignment) %>_recount">
|
||||||
<% if total_recounts.present? %>
|
<% if total_recounts.present? %>
|
||||||
<strong><%= total_recounts %></strong>
|
<strong><%= total_recounts %></strong>
|
||||||
<% else %>
|
<% else %>
|
||||||
@@ -58,6 +67,8 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% unless @poll.recounts_confirmed? %>
|
||||||
<td class="text-center" id="<%= dom_id(booth_assignment) %>_system">
|
<td class="text-center" id="<%= dom_id(booth_assignment) %>_system">
|
||||||
<% if system_count.present? %>
|
<% if system_count.present? %>
|
||||||
<strong><%= system_count %></strong>
|
<strong><%= system_count %></strong>
|
||||||
@@ -65,6 +76,7 @@
|
|||||||
<span>0</span>
|
<span>0</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ FactoryBot.define do
|
|||||||
ends_at { 15.days.ago }
|
ends_at { 15.days.ago }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :old do
|
||||||
|
starts_at { 3.months.ago }
|
||||||
|
ends_at { 2.months.ago }
|
||||||
|
end
|
||||||
|
|
||||||
trait :recounting do
|
trait :recounting do
|
||||||
starts_at { 1.month.ago }
|
starts_at { 1.month.ago }
|
||||||
ends_at { Date.current }
|
ends_at { Date.current }
|
||||||
|
|||||||
@@ -328,6 +328,27 @@ describe "Admin polls" do
|
|||||||
expect(page).to have_content("2")
|
expect(page).to have_content("2")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Recounts list with old polls" do
|
||||||
|
poll = create(:poll, :old)
|
||||||
|
booth_assignment = create(:poll_booth_assignment, poll: poll)
|
||||||
|
|
||||||
|
create(:poll_recount, booth_assignment: booth_assignment, total_amount: 10)
|
||||||
|
create(:poll_voter, :from_booth, poll: poll, booth_assignment: booth_assignment)
|
||||||
|
|
||||||
|
visit admin_poll_recounts_path(poll)
|
||||||
|
|
||||||
|
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).to have_selector "#poll_booth_assignment_#{booth_assignment.id}_recounts"
|
||||||
|
expect(page).not_to have_selector "#poll_booth_assignment_#{booth_assignment.id}_system"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -414,4 +414,30 @@ describe Poll do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#recounts_confirmed" do
|
||||||
|
it "is false for current polls" do
|
||||||
|
poll = create(:poll, :current)
|
||||||
|
|
||||||
|
expect(poll.recounts_confirmed?).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "is false for recounting polls" do
|
||||||
|
poll = create(:poll, :recounting)
|
||||||
|
|
||||||
|
expect(poll.recounts_confirmed?).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "is false for polls which finished less than a month ago" do
|
||||||
|
poll = create(:poll, starts_at: 3.months.ago, ends_at: 27.days.ago )
|
||||||
|
|
||||||
|
expect(poll.recounts_confirmed?).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "is true for polls which finished more than a month ago" do
|
||||||
|
poll = create(:poll, starts_at: 3.months.ago, ends_at: 1.month.ago - 1.day)
|
||||||
|
|
||||||
|
expect(poll.recounts_confirmed?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user