mirror of
https://github.com/discourse/discourse.git
synced 2025-09-10 12:04:21 +08:00
BUGFIX: UserStat spec was over ambitious with its mocking
This commit is contained in:
parent
b703d8c77a
commit
6befdceabf
2 changed files with 19 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue