From 548ab91398003c6aa4177d05858d5269deef010d Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Thu, 24 Jun 2021 15:37:59 +0000 Subject: [PATCH] Fixes #3632 - Monitoring endpoint complains about Failed to run SessionTimeoutJob.perform_now after 10 tries # user.id, + 'user_id' => user&.id, 'ping' => Time.zone.now, 'user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36', '_csrf_token' => 'Yq3XiEgXxWPCURa/FvpXmptZCjgWhyPpGGIvZj9Eea0=' diff --git a/spec/jobs/session_timeout_job_spec.rb b/spec/jobs/session_timeout_job_spec.rb index ed943f29b..ecff6d42e 100644 --- a/spec/jobs/session_timeout_job_spec.rb +++ b/spec/jobs/session_timeout_job_spec.rb @@ -183,4 +183,18 @@ RSpec.describe SessionTimeoutJob, type: :job do expect(PushMessages).not_to have_received(:send_to).with(user.id, { event: 'session_timeout' }) end end + + context 'without user in session' do + let(:user) { create(:admin) } + + before do + Setting.set('session_timeout', { admin: 30.minutes.to_s }) + create(:active_session, user: nil) + end + + it 'does not crash' do + travel_to 1.hour.from_now + expect { described_class.perform_now }.not_to raise_error + end + end end