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:
@@ -273,7 +273,7 @@ describe Debate do
|
|||||||
newer_debate = create(:debate, created_at: now)
|
newer_debate = create(:debate, created_at: now)
|
||||||
5.times { newer_debate.vote_by(voter: create(:user), vote: "yes") }
|
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") }
|
5.times { older_debate.vote_by(voter: create(:user), vote: "yes") }
|
||||||
|
|
||||||
expect(newer_debate.hot_score).to be > older_debate.hot_score
|
expect(newer_debate.hot_score).to be > older_debate.hot_score
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ describe Legislation::Proposal do
|
|||||||
newer_proposal = create(:legislation_proposal, created_at: now)
|
newer_proposal = create(:legislation_proposal, created_at: now)
|
||||||
5.times { newer_proposal.vote_by(voter: create(:user), vote: "yes") }
|
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") }
|
5.times { older_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||||
|
|
||||||
expect(newer_proposal.hot_score).to be > older_proposal.hot_score
|
expect(newer_proposal.hot_score).to be > older_proposal.hot_score
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ describe Proposal do
|
|||||||
newer_proposal = create(:proposal, created_at: now)
|
newer_proposal = create(:proposal, created_at: now)
|
||||||
5.times { newer_proposal.vote_by(voter: create(:user), vote: "yes") }
|
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") }
|
5.times { older_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||||
|
|
||||||
expect(newer_proposal.hot_score).to be > older_proposal.hot_score
|
expect(newer_proposal.hot_score).to be > older_proposal.hot_score
|
||||||
|
|||||||
Reference in New Issue
Block a user