From 1ec12fc8086749981b10fbaab3e72fc94a271b52 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 28 Jun 2013 16:07:36 +1000 Subject: [PATCH] this spec is just refusing to work on jenkins --- app/models/user.rb | 3 ++- spec/models/user_spec.rb | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 3bfcd676347..82651e6a4ab 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -285,8 +285,9 @@ class User < ActiveRecord::Base def update_last_seen!(now=nil) now ||= Time.zone.now now_date = now.to_date + # Only update last seen once every minute - redis_key = "user:#{self.id}:#{now_date.to_s}" + redis_key = "user:#{self.id}:last_seen" if $redis.setnx(redis_key, "1") $redis.expire(redis_key, SiteSetting.active_user_rate_limit_secs) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 723ee740c35..d26be8d7ff1 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -592,6 +592,7 @@ describe User do before do SiteSetting.stubs(:active_user_rate_limit_secs).returns(0) + SiteSetting.stubs(:previous_visit_timeout_hours).returns(1) end it "should act correctly" do @@ -601,6 +602,11 @@ describe User do user.update_last_seen!(first_visit_date) user.previous_visit_at.should be_nil + # updated same time + user.update_last_seen!(first_visit_date) + user.reload + user.previous_visit_at.should be_nil + # second visit user.update_last_seen!(second_visit_date) user.reload @@ -610,7 +616,6 @@ describe User do user.update_last_seen!(third_visit_date) user.reload user.previous_visit_at.should be_within_one_second_of(second_visit_date) - end end