Fix booth recounts poll stats discrepancies

Due to technical issues, sometimes users voted in booths and their vote
couldn't be added to the database. So we're including them in the users
with no demographic data.
This commit is contained in:
Javi Martín
2019-04-11 15:59:26 +02:00
parent 483ebffb47
commit 42a25ded3f
2 changed files with 40 additions and 0 deletions

View File

@@ -186,6 +186,34 @@ describe Poll::Stats do
end
end
describe "#total_no_demographic_data" do
before do
create(:poll_voter, :from_web, poll: poll, user: create(:user, :level_two, gender: nil))
end
context "more registered participants than participants in recounts" do
before do
create(:poll_recount, :from_booth, poll: poll, total_amount: 1)
2.times { create(:poll_voter, :from_booth, poll: poll) }
end
it "returns registered users with no demographic data" do
expect(stats.total_no_demographic_data).to eq 1
end
end
context "more participants in recounts than registered participants" do
before do
create(:poll_recount, :from_booth, poll: poll, total_amount: 3)
2.times { create(:poll_voter, :from_booth, poll: poll) }
end
it "returns registered users with no demographic data plus users not registered" do
expect(stats.total_no_demographic_data).to eq 2
end
end
end
describe "#channels" do
context "no participants" do
it "returns no channels" do