FIX: extract reset_last_seen_cache! in user_spec (#9808)
Helper method to avoid code duplication
This commit is contained in:
parent
e81a4048e3
commit
ea63fa7de7
|
@ -874,7 +874,7 @@ describe User do
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Discourse.redis.del("user:#{user.id}:#{Time.zone.now.to_date}")
|
reset_last_seen_cache!(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should act correctly" do
|
it "should act correctly" do
|
||||||
|
@ -908,7 +908,7 @@ describe User do
|
||||||
let!(:second_visit_date) { 2.hours.from_now }
|
let!(:second_visit_date) { 2.hours.from_now }
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Discourse.redis.del("user:#{user.id}:#{Time.zone.now.to_date}")
|
reset_last_seen_cache!(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should update the last seen value" do
|
it "should update the last seen value" do
|
||||||
|
@ -984,9 +984,9 @@ describe User do
|
||||||
|
|
||||||
describe 'with no previous values' do
|
describe 'with no previous values' do
|
||||||
after do
|
after do
|
||||||
Discourse.redis.del("user:#{user.id}:#{Time.zone.now.to_date}")
|
reset_last_seen_cache!(user)
|
||||||
unfreeze_time
|
unfreeze_time
|
||||||
Discourse.redis.del("user:#{user.id}:#{Time.zone.now.to_date}")
|
reset_last_seen_cache!(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates last_seen_at" do
|
it "updates last_seen_at" do
|
||||||
|
@ -1316,7 +1316,7 @@ describe User do
|
||||||
let!(:now) { Time.zone.now }
|
let!(:now) { Time.zone.now }
|
||||||
before { user.update_last_seen!(now) }
|
before { user.update_last_seen!(now) }
|
||||||
after do
|
after do
|
||||||
Discourse.redis.del("user:#{user.id}:#{now.to_date}")
|
reset_last_seen_cache!(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "with existing UserVisit record, increments the posts_read value" do
|
it "with existing UserVisit record, increments the posts_read value" do
|
||||||
|
@ -2374,4 +2374,8 @@ describe User do
|
||||||
expect(user2.recent_time_read).to eq(50)
|
expect(user2.recent_time_read).to eq(50)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset_last_seen_cache!(user)
|
||||||
|
Discourse.redis.del("user:#{user.id}:#{Time.zone.now.to_date}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue