DEV: Improve flaky time-sensitive specs (#9141)

This commit is contained in:
Jarek Radosz
2020-03-10 22:13:17 +01:00
committed by GitHub
parent f795c1b8e8
commit 29b35aa64c
49 changed files with 334 additions and 331 deletions

View File

@ -11,7 +11,6 @@ describe PostsController do
end
describe "polls" do
it "works" do
post :create, params: {
title: title, raw: "[poll]\n- A\n- B\n[/poll]"
@ -39,7 +38,7 @@ describe PostsController do
it "schedules auto-close job" do
freeze_time
name = "auto_close"
close_date = 1.month.from_now
close_date = 1.month.from_now.round
expect do
post :create, params: {
@ -53,7 +52,7 @@ describe PostsController do
json = ::JSON.parse(response.body)
post_id = json["id"]
expect(Poll.find_by(post_id: post_id).close_at).to be_within_one_second_of(1.month.from_now)
expect(Poll.find_by(post_id: post_id).close_at).to eq_time(close_date)
job = Jobs::ClosePoll.jobs.first
job_args = job["args"].first