DEV: improve flaky spec

This handles a lot of date calculations, keep the baseline time consistent
so it is not prone to issues when running out UTC threshold
This commit is contained in:
Sam Saffron 2019-10-04 11:11:03 +10:00
parent a49e484519
commit 926bd712bf

View File

@ -51,6 +51,7 @@ describe DirectoryItem do
context 'refresh' do
before do
freeze_time DateTime.parse('2017-02-02 12:00')
UserActionManager.enable
end
@ -89,11 +90,13 @@ describe DirectoryItem do
it "handles users with no activity" do
post = nil
freeze_time(2.years.ago) do
post = create_post
# Create records for that activity
DirectoryItem.refresh!
end
freeze_time(2.years.ago)
post = create_post
# Create records for that activity
DirectoryItem.refresh!
freeze_time(2.years.from_now)
DirectoryItem.refresh!
[:yearly, :monthly, :weekly, :daily, :quarterly].each do |period|