BUGFIX: UserStat spec was over ambitious with its mocking

This commit is contained in:
Sam
2014-01-06 16:50:55 +11:00
parent b703d8c77a
commit 6befdceabf
2 changed files with 19 additions and 7 deletions

View File

@ -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