sessions: fix error when an anonymous user tried to logout.

Fix an exception when a user who was already logged out tried to logout
again.
This commit is contained in:
evazion
2021-01-23 18:22:43 -06:00
parent b6e06ee6fc
commit 9a9fbcc398
2 changed files with 12 additions and 4 deletions

View File

@@ -75,18 +75,25 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
end
context "destroy action" do
setup do
delete_auth session_path, @user
end
should "clear the session" do
delete_auth session_path, @user
assert_redirected_to posts_path
assert_nil(session[:user_id])
end
should "generate a logout event" do
delete_auth session_path, @user
assert_equal(true, @user.user_events.logout.exists?)
end
should "not fail if the user is already logged out" do
delete session_path
assert_redirected_to posts_path
assert_nil(session[:user_id])
end
end
context "sign_out action" do