From fe7f2c6979393f1184271dcc54a350d11d821715 Mon Sep 17 00:00:00 2001 From: Erick Guan Date: Mon, 29 Dec 2014 20:29:09 +0800 Subject: [PATCH] FIX: today visits not shown --- app/models/report.rb | 2 +- spec/models/report_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/report.rb b/app/models/report.rb index 1ddf45cf1..8e34a68a2 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -46,7 +46,7 @@ class Report end def self.report_visits(report) - basic_report_about report, UserVisit, :by_day, report.start_date, report.end_date + basic_report_about report, UserVisit, :by_day, report.start_date, report.end_date.change(hour: 24) end def self.report_signups(report) diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index 02b806dee..e19567cc5 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -15,6 +15,7 @@ describe Report do let(:user) { Fabricate(:user) } before do + user.user_visits.create(visited_at: 1.hour.ago) user.user_visits.create(visited_at: 1.day.ago) user.user_visits.create(visited_at: 2.days.ago) end @@ -22,6 +23,10 @@ describe Report do it "returns a report with data" do report.data.should be_present end + + it "return today's visit" do + report.data.select { |v| v[:x].today? }.should be_present + end end end