|
|
|
@ -44,16 +44,16 @@ describe 'Expire old user sessions', |
|
|
|
|
describe 'logging in again' do |
|
|
|
|
context 'with drop_old_sessions enabled', with_config: { drop_old_sessions_on_login: true } do |
|
|
|
|
it 'destroys the old session' do |
|
|
|
|
expect(::Sessions::ActiveRecord.count).to eq(1) |
|
|
|
|
expect(::Sessions::UserSession.count).to eq(1) |
|
|
|
|
|
|
|
|
|
first_session = ::Sessions::ActiveRecord.first |
|
|
|
|
first_session = ::Sessions::UserSession.first |
|
|
|
|
expect(first_session.user_id).to eq(admin.id) |
|
|
|
|
|
|
|
|
|
# Actually login now |
|
|
|
|
login_with(admin.login, admin_password) |
|
|
|
|
|
|
|
|
|
expect(::Sessions::ActiveRecord.count).to eq(1) |
|
|
|
|
second_session = ::Sessions::ActiveRecord.first |
|
|
|
|
expect(::Sessions::UserSession.count).to eq(1) |
|
|
|
|
second_session = ::Sessions::UserSession.first |
|
|
|
|
|
|
|
|
|
expect(second_session.user_id).to eq(admin.id) |
|
|
|
|
expect(second_session.session_id).not_to eq(first_session.session_id) |
|
|
|
@ -65,7 +65,7 @@ describe 'Expire old user sessions', |
|
|
|
|
# Actually login now |
|
|
|
|
login_with(admin.login, admin_password) |
|
|
|
|
|
|
|
|
|
expect(::Sessions::ActiveRecord.for_user(admin).count).to eq(2) |
|
|
|
|
expect(::Sessions::UserSession.for_user(admin).count).to eq(2) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -74,23 +74,23 @@ describe 'Expire old user sessions', |
|
|
|
|
before do |
|
|
|
|
# Actually login now |
|
|
|
|
login_with(admin.login, admin_password) |
|
|
|
|
expect(::Sessions::ActiveRecord.for_user(admin).count).to eq(2) |
|
|
|
|
expect(::Sessions::UserSession.for_user(admin).count).to eq(2) |
|
|
|
|
visit '/logout' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with drop_old_sessions enabled', with_config: { drop_old_sessions_on_logout: true } do |
|
|
|
|
it 'destroys the old session' do |
|
|
|
|
# A fresh session is opened due to reset_session |
|
|
|
|
expect(::Sessions::ActiveRecord.for_user(admin).count).to eq(0) |
|
|
|
|
expect(::Sessions::ActiveRecord.non_user.count).to eq(1) |
|
|
|
|
expect(::Sessions::UserSession.for_user(admin).count).to eq(0) |
|
|
|
|
expect(::Sessions::UserSession.non_user.count).to eq(1) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with drop_old_sessions disabled', |
|
|
|
|
with_config: { drop_old_sessions_on_logout: false } do |
|
|
|
|
it 'keeps the old session' do |
|
|
|
|
expect(::Sessions::ActiveRecord.count).to eq(2) |
|
|
|
|
expect(::Sessions::ActiveRecord.for_user(admin).count).to eq(1) |
|
|
|
|
expect(::Sessions::UserSession.count).to eq(2) |
|
|
|
|
expect(::Sessions::UserSession.for_user(admin).count).to eq(1) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|