Include booth users in participants in vote phase

We were expecting `balloters` to include `poll_ballot_voters` (that's
why we're substracting them to calculate web participants), but reality
has proven `poll_ballot_voters` aren't included in `balloters`.
This commit is contained in:
Javi Martín
2019-03-26 20:36:12 +01:00
parent cf32cc940b
commit d42454a1a8
2 changed files with 16 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ class Budget::Stats
end
def total_participants_vote_phase
balloters.uniq.count
(balloters + poll_ballot_voters).uniq.count
end
def total_budget_investments

View File

@@ -70,6 +70,21 @@ describe Budget::Stats do
expect(stats.generate[:total_participants_vote_phase]).to be 1
end
it "includes balloters and poll balloters" do
create(:budget_ballot_line, investment: investment)
create(:poll_voter, :from_booth, budget: budget)
expect(stats.generate[:total_participants_vote_phase]).to be 2
end
it "counts once a user who is balloter and poll balloter" do
poller_and_balloter = create(:user, :level_two)
create(:budget_ballot_line, investment: investment, user: poller_and_balloter)
create(:poll_voter, :from_booth, user: poller_and_balloter, budget: budget)
expect(stats.generate[:total_participants_vote_phase]).to be 1
end
it "doesn't count nil user ids" do
create(:budget_ballot_line, investment: investment,
ballot: create(:budget_ballot, budget: budget, user: nil, physical: true)