Exclude nil balloters from vote phase participants
The `user_id` can be `nil` for ballots.
This commit is contained in:
@@ -65,7 +65,7 @@ class Budget::Stats
|
|||||||
end
|
end
|
||||||
|
|
||||||
def balloters
|
def balloters
|
||||||
budget.ballots.where("ballot_lines_count > ?", 0).pluck(:user_id)
|
budget.ballots.where("ballot_lines_count > ?", 0).pluck(:user_id).compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def poll_ballot_voters
|
def poll_ballot_voters
|
||||||
|
|||||||
@@ -69,6 +69,14 @@ describe Budget::Stats do
|
|||||||
|
|
||||||
expect(stats.generate[:total_participants_vote_phase]).to be 1
|
expect(stats.generate[:total_participants_vote_phase]).to be 1
|
||||||
end
|
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)
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(stats.generate[:total_participants_vote_phase]).to be 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#total_participants_web" do
|
describe "#total_participants_web" do
|
||||||
|
|||||||
Reference in New Issue
Block a user