From 00a42be5c0bb2090d8ad7a3c8705ec9a5ea0e255 Mon Sep 17 00:00:00 2001 From: Pablo Porto Date: Mon, 8 Apr 2024 13:26:46 +0200 Subject: [PATCH] fix(authentication): Fix issues when users try to logout (#603) Run set last login information action only when the user exist. Thus preventing running it after the logout method, which was causing an error --- app/controllers/concerns/authentication.rb | 2 +- test/application_system_test_case.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/authentication.rb b/app/controllers/concerns/authentication.rb index 64d0a8c0..01a4f297 100644 --- a/app/controllers/concerns/authentication.rb +++ b/app/controllers/concerns/authentication.rb @@ -3,7 +3,7 @@ module Authentication included do before_action :authenticate_user! - after_action :set_last_login_at + after_action :set_last_login_at, if: -> { Current.user } end class_methods do diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 42eb8460..431da1d5 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -12,6 +12,9 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase fill_in "Password", with: "password" click_button "Log in" end - assert_text "Dashboard" + assert_text "Dashboard", wait: 5 + find('[data-controller="menu"]').click + click_button "Logout" + assert_text "Sign in to your account" end end