From 83e129d5b785c516d66651e249aa1220ca280274 Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Sun, 31 Mar 2019 15:48:54 +0200 Subject: [PATCH] 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. --- spec/models/debate_spec.rb | 2 +- spec/models/legislation/proposal_spec.rb | 2 +- spec/models/proposal_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/debate_spec.rb b/spec/models/debate_spec.rb index 12da638ee..8f4745007 100644 --- a/spec/models/debate_spec.rb +++ b/spec/models/debate_spec.rb @@ -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 diff --git a/spec/models/legislation/proposal_spec.rb b/spec/models/legislation/proposal_spec.rb index 28ea9c72d..f2f72b055 100644 --- a/spec/models/legislation/proposal_spec.rb +++ b/spec/models/legislation/proposal_spec.rb @@ -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 diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index 334eee502..3f08f011a 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -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