freeze time in report spec so it has consistent results

This commit is contained in:
Sam 2015-02-05 11:33:13 +11:00
parent c9adfa65a0
commit eb7a5c251d

View file

@ -14,19 +14,15 @@ describe Report do
context "with visits" do context "with visits" do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
before(:each) do it "returns a report with data" do
user.user_visits.create(visited_at: 1.hour.ago) freeze_time DateTime.parse('2000-01-01')
user.user_visits.create(visited_at: 1.hour.from_now)
user.user_visits.create(visited_at: 1.day.ago) user.user_visits.create(visited_at: 1.day.ago)
user.user_visits.create(visited_at: 2.days.ago) user.user_visits.create(visited_at: 2.days.ago)
end
it "returns a report with data" do
expect(report.data).to be_present expect(report.data).to be_present
end
it "returns today's visit" do
expect(report.data.select { |v| v[:x].today? }).to be_present expect(report.data.select { |v| v[:x].today? }).to be_present
end end
end end
end end