Fix failing tests

If tests run very fast all votes are created within the last 24
hours, so hot_score has the same value if the creation date for the
votes is Time.current or 1.day.ago.

Creating the votes 48 hours ago we make sure hot_score has the
correct value and the tests pass correctly.
This commit is contained in:
Julian Herrero
2019-03-31 15:48:54 +02:00
parent 4b57c3d8eb
commit 83e129d5b7
3 changed files with 3 additions and 3 deletions

View File

@@ -273,7 +273,7 @@ describe Debate do
newer_debate = create(:debate, created_at: now)
5.times { newer_debate.vote_by(voter: create(:user), vote: "yes") }
older_debate = create(:debate, created_at: 1.day.ago)
older_debate = create(:debate, created_at: 2.days.ago)
5.times { older_debate.vote_by(voter: create(:user), vote: "yes") }
expect(newer_debate.hot_score).to be > older_debate.hot_score

View File

@@ -67,7 +67,7 @@ describe Legislation::Proposal do
newer_proposal = create(:legislation_proposal, created_at: now)
5.times { newer_proposal.vote_by(voter: create(:user), vote: "yes") }
older_proposal = create(:legislation_proposal, created_at: 1.day.ago)
older_proposal = create(:legislation_proposal, created_at: 2.day.ago)
5.times { older_proposal.vote_by(voter: create(:user), vote: "yes") }
expect(newer_proposal.hot_score).to be > older_proposal.hot_score

View File

@@ -291,7 +291,7 @@ describe Proposal do
newer_proposal = create(:proposal, created_at: now)
5.times { newer_proposal.vote_by(voter: create(:user), vote: "yes") }
older_proposal = create(:proposal, created_at: 1.day.ago)
older_proposal = create(:proposal, created_at: 2.days.ago)
5.times { older_proposal.vote_by(voter: create(:user), vote: "yes") }
expect(newer_proposal.hot_score).to be > older_proposal.hot_score