2013-02-05 14:16:51 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UserVisit do
|
2013-04-05 02:43:48 -04:00
|
|
|
it 'can ensure consistency' do
|
|
|
|
u = Fabricate(:user)
|
|
|
|
u.update_visit_record!(2.weeks.ago.to_date)
|
|
|
|
u.last_seen_at = 2.weeks.ago
|
|
|
|
u.save
|
|
|
|
u.update_visit_record!(1.day.ago.to_date)
|
|
|
|
|
|
|
|
u.reload
|
2013-10-03 23:28:49 -04:00
|
|
|
u.user_stat.days_visited.should == 2
|
2013-04-05 02:43:48 -04:00
|
|
|
|
2013-10-03 23:28:49 -04:00
|
|
|
u.user_stat.days_visited = 1
|
2013-04-07 18:19:35 -04:00
|
|
|
u.save
|
2013-04-05 02:43:48 -04:00
|
|
|
UserVisit.ensure_consistency!
|
|
|
|
|
|
|
|
u.reload
|
2013-10-03 23:28:49 -04:00
|
|
|
u.user_stat.days_visited.should == 2
|
2013-04-05 02:43:48 -04:00
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|