Sha256: 71bb8ad3c350d306ee22e12283a3590c8abee4fc670f872de0692016ff0a8bd6
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require_relative 'test_helper' class ActionControllerTestExtensionsTest < ActionController::TestCase def setup @user = users(:john) @token = credentials(:john_session_token) end test 'session_current_user for no user' do assert_nil session_current_user end test 'session_current_user with valid suid' do request.session[:authpwn_suid] = @token.suid assert_equal @user, session_current_user end test 'set_session_current_user reuses existing token' do assert_no_difference -> { Credential.count } do set_session_current_user @user end assert_equal @token.suid, request.session[:authpwn_suid] end test 'set_session_current_user creates token if necessary' do @token.destroy assert_difference -> { Credential.count }, 1 do set_session_current_user @user end assert_equal @user, session_current_user end test 'set_session_current_user to nil' do request.session[:authpwn_suid] = @token.suid assert_no_difference -> { Credential.count } do set_session_current_user nil end assert_nil request.session[:authpwn_suid] end end
Version data entries
3 entries across 3 versions & 1 rubygems