Sha256: 20fc84b77a27b63cf1834141e9126765724c2ec06a83361d8a470844d240c686
Contents?: true
Size: 2 KB
Versions: 4
Compression:
Stored size: 2 KB
Contents
require 'test_helper' class TestSessionLimitableWorkflow < ActionDispatch::IntegrationTest include IntegrationHelpers setup do @user = User.create!(password: 'passWord1', password_confirmation: 'passWord1', email: 'bob@microsoft.com') @user.confirm end test 'failed login' do assert_nil @user.unique_session_id open_session do |session| failed_sign_in(@user, session) session.assert_response(:success) assert_equal session.flash[:alert], I18n.t('devise.failure.invalid', authentication_keys: 'Email') assert_nil @user.reload.unique_session_id end end test 'successful login' do assert_nil @user.unique_session_id open_session do |session| sign_in(@user, session) session.assert_redirected_to '/' session.get widgets_path session.assert_response(:success) assert_equal session.response.body, 'success' assert_not_nil @user.reload.unique_session_id end end test 'session is logged out when another session is created' do first_session = open_session second_session = open_session unique_session_id = nil first_session.tap do |session| sign_in(@user, session) session.assert_redirected_to '/' session.get widgets_path session.assert_response(:success) assert_equal session.response.body, 'success' unique_session_id = @user.reload.unique_session_id assert_not_nil unique_session_id end second_session.tap do |session| sign_in(@user, session) session.assert_redirected_to '/' session.get widgets_path session.assert_response(:success) assert_equal session.response.body, 'success' assert_not_equal unique_session_id, @user.reload.unique_session_id end first_session.tap do |session| session.get widgets_path session.assert_redirected_to new_user_session_path assert_equal session.flash[:alert], I18n.t('devise.failure.session_limited') end end end
Version data entries
4 entries across 4 versions & 1 rubygems