Don't include current polls in recounting polls
On the day when a poll ends, it was considered both current and recounting.
This commit is contained in:
@@ -44,7 +44,7 @@ class Poll < ApplicationRecord
|
||||
scope :for, ->(element) { where(related: element) }
|
||||
scope :current, -> { where("starts_at <= ? and ? <= ends_at", Date.current.beginning_of_day, Date.current.beginning_of_day) }
|
||||
scope :expired, -> { where("ends_at < ?", Date.current.beginning_of_day) }
|
||||
scope :recounting, -> { where(ends_at: (Date.current.beginning_of_day - RECOUNT_DURATION)..Date.current.beginning_of_day) }
|
||||
scope :recounting, -> { where(ends_at: (Date.current.beginning_of_day - RECOUNT_DURATION)...Date.current.beginning_of_day) }
|
||||
scope :published, -> { where(published: true) }
|
||||
scope :by_geozone_id, ->(geozone_id) { where(geozones: { id: geozone_id }.joins(:geozones)) }
|
||||
scope :public_for_api, -> { all }
|
||||
|
||||
@@ -358,7 +358,7 @@ describe Poll do
|
||||
describe ".recounting" do
|
||||
it "returns polls in recount & scrutiny phase" do
|
||||
about_to_start = create(:poll, starts_at: Date.tomorrow)
|
||||
about_to_end = create(:poll, ends_at: Date.tomorrow)
|
||||
about_to_end = create(:poll, ends_at: Date.current)
|
||||
just_ended = create(:poll, ends_at: Date.yesterday)
|
||||
recounting_ended = create(:poll, starts_at: 3.years.ago, ends_at: 2.years.ago)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user