discourse/plugins/discourse-rewind/spec/plugin_helper.rb
Jarek Radosz 7b1c9cc3dc
FIX: Correct the date range in d-rewind (#39805)
Fixes the flakes we've been seeing.

1. The previous version of `random_datetime` could sometimes fall
outside the desired range (roughly in 2% of runs)
2. `Date.new(year).all_year` is a `Date` range. It's turned into
`BETWEEN '2021-01-01' AND '2021-12-31'` which pg reads as midnight
timestamps, so we've been dropping any activity after Dec 31 00:00.
(i.e. the last 24hrs)
2026-05-06 19:58:21 +02:00

14 lines
362 B
Ruby

# frozen_string_literal: true
module DiscourseRewindSpecHelper
def call_report
# user + date should be defined via fab! in the spec
described_class.call(user:, date:, guardian: user.guardian)
end
def random_datetime
rand(date.first.to_time...date.last.to_time)
end
end
RSpec.configure { |config| config.include DiscourseRewindSpecHelper }