Include blank and null ballots in booth totals
Just the same way it's done for all polls.
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
module PollRecountsHelper
|
module PollRecountsHelper
|
||||||
|
|
||||||
def total_recounts_by_booth(booth_assignment)
|
def total_recounts_by_booth(booth_assignment)
|
||||||
booth_assignment.recounts.any? ? booth_assignment.recounts.to_a.sum(&:total_amount) : nil
|
if booth_assignment.recounts.any?
|
||||||
|
booth_assignment.recounts.sum(:total_amount) +
|
||||||
|
booth_assignment.recounts.sum(:white_amount) +
|
||||||
|
booth_assignment.recounts.sum(:null_amount)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
13
spec/helpers/poll_recounts_helper_spec.rb
Normal file
13
spec/helpers/poll_recounts_helper_spec.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
describe PollRecountsHelper do
|
||||||
|
describe "#total_recounts_by_booth" do
|
||||||
|
it "includes blank and null votes" do
|
||||||
|
assignment = create(:poll_booth_assignment)
|
||||||
|
create(:poll_recount, :from_booth, booth_assignment: assignment, total_amount: 3, white_amount: 1)
|
||||||
|
create(:poll_recount, :from_booth, booth_assignment: assignment, total_amount: 4, null_amount: 2)
|
||||||
|
|
||||||
|
expect(total_recounts_by_booth(assignment)).to eq 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user