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

@@ -415,12 +415,14 @@ describe PostsController do
end
it "won't update bump date if post is a whisper" do
created_at = freeze_time 1.day.ago
post = Fabricate(:post, post_type: Post.types[:whisper], user: user)
unfreeze_time
put "/posts/#{post.id}.json", params: update_params
expect(response.status).to eq(200)
expect(post.topic.reload.bumped_at).to be < post.created_at
expect(response.status).to eq(200)
expect(post.topic.reload.bumped_at).to eq_time(created_at)
end
end
@@ -1314,10 +1316,10 @@ describe PostsController do
context "topic bump" do
shared_examples "it works" do
let(:original_bumped_at) { 1.day.ago }
let!(:topic) { Fabricate(:topic, bumped_at: original_bumped_at) }
it "should be able to skip topic bumping" do
original_bumped_at = 1.day.ago
topic = Fabricate(:topic, bumped_at: original_bumped_at)
post "/posts.json", params: {
raw: 'this is the test content',
topic_id: topic.id,
@@ -1325,7 +1327,7 @@ describe PostsController do
}
expect(response.status).to eq(200)
expect(topic.reload.bumped_at).to be_within_one_second_of(original_bumped_at)
expect(topic.reload.bumped_at).to eq_time(original_bumped_at)
end
it "should be able to post with topic bumping" do
@@ -1335,7 +1337,7 @@ describe PostsController do
}
expect(response.status).to eq(200)
expect(topic.reload.bumped_at).to eq(topic.posts.last.created_at)
expect(topic.reload.bumped_at).to eq_time(topic.posts.last.created_at)
end
end