From 354376795148d0b12a9b8e2e017526c9b730cfa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 7 Sep 2022 19:44:23 +0200 Subject: [PATCH] Don't include current polls in recounting polls On the day when a poll ends, it was considered both current and recounting. --- app/models/poll.rb | 2 +- spec/models/poll/poll_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 48cffaace..7b127c64d 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -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 } diff --git a/spec/models/poll/poll_spec.rb b/spec/models/poll/poll_spec.rb index c7b4656cf..a2b94d729 100644 --- a/spec/models/poll/poll_spec.rb +++ b/spec/models/poll/poll_spec.rb @@ -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)