fixed a pile of notification craziness

addes some tests around post timings
This commit is contained in:
Sam Saffron
2013-02-25 18:42:42 +11:00
parent cb3d839104
commit 77a2d8ccc4
7 changed files with 116 additions and 49 deletions

View File

@ -652,9 +652,6 @@ describe User do
end
end
end
describe '#create_for_email' do
@ -691,4 +688,32 @@ describe User do
end
end
describe 'update_time_read!' do
let(:user) { Fabricate(:user) }
it 'makes no changes if nothing is cached' do
$redis.expects(:get).with("user-last-seen:#{user.id}").returns(nil)
user.update_time_read!
user.reload
user.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)
user.update_time_read!
user.reload
user.time_read.should == 10
end
it 'makes no change if time read is above threshold' do
t = Time.now - 1 - User::MAX_TIME_READ_DIFF
$redis.expects(:get).with("user-last-seen:#{user.id}").returns(t)
user.update_time_read!
user.reload
user.time_read.should == 0
end
end
end