Pull to concern

This commit is contained in:
Andrew Tomaka 2024-08-16 19:21:44 -04:00
parent cb47e6bb73
commit 28620e27d7
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
3 changed files with 22 additions and 7 deletions

View file

@ -1,9 +1,3 @@
class ApplicationController < ActionController::Base
before_action :authenticate_user
private
def authenticate_user
Current.user = User.find_by(id: session[:current_user_id])
end
include Authenticatable
end

View file

@ -0,0 +1,13 @@
module Authenticatable
extend ActiveSupport::Concern
included do
before_action :authenticate_user
end
private
def authenticate_user
Current.user = User.find_by(id: session[:current_user_id])
end
end

View file

@ -17,6 +17,14 @@ class SessionsTest < ApplicationSystemTestCase
end
test "should destroy Session" do
visit new_session_url
fill_in "Email", with: @user.email
fill_in "Password", with: "secret"
click_on "Create Session"
assert_text "Session was successfully created"
visit root_url
click_on "Log out", match: :first