mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
BUGFIX: UserStat spec was over ambitious with its mocking
This commit is contained in:
@ -77,14 +77,14 @@ describe UserStat do
|
||||
let(:stat) { user.user_stat }
|
||||
|
||||
it 'makes no changes if nothing is cached' do
|
||||
$redis.expects(:get).with("user-last-seen:#{user.id}").returns(nil)
|
||||
stat.expects(:last_seen_cached).returns(nil)
|
||||
stat.update_time_read!
|
||||
stat.reload
|
||||
stat.time_read.should == 0
|
||||
end
|
||||
|
||||
it 'makes a change if time read is below threshold' do
|
||||
$redis.expects(:get).with("user-last-seen:#{user.id}").returns(Time.now - 10.0)
|
||||
stat.expects(:last_seen_cached).returns(Time.now - 10)
|
||||
stat.update_time_read!
|
||||
stat.reload
|
||||
stat.time_read.should == 10
|
||||
@ -92,7 +92,7 @@ describe UserStat do
|
||||
|
||||
it 'makes no change if time read is above threshold' do
|
||||
t = Time.now - 1 - UserStat::MAX_TIME_READ_DIFF
|
||||
$redis.expects(:get).with("user-last-seen:#{user.id}").returns(t)
|
||||
stat.expects(:last_seen_cached).returns(t)
|
||||
stat.update_time_read!
|
||||
stat.reload
|
||||
stat.time_read.should == 0
|
||||
|
Reference in New Issue
Block a user