forget_insecure_sessions_spec.rb 733 B

12345678910111213141516171819202122232425262728
  1. require 'rails_helper'
  2. RSpec.describe ForgetInsecureSessions, type: :db_migration do
  3. before do
  4. 5.times do
  5. ActiveRecord::SessionStore::Session.create(
  6. session_id: SecureRandom.hex(16),
  7. data: SecureRandom.base64(10)
  8. )
  9. end
  10. end
  11. context 'for HTTP deployment' do
  12. before { Setting.set('http_type', 'http') }
  13. it 'does not delete existing sessions' do
  14. expect { migrate }.not_to change(ActiveRecord::SessionStore::Session, :count)
  15. end
  16. end
  17. context 'for HTTPS deployment' do
  18. before { Setting.set('http_type', 'https') }
  19. it 'deletes all existing sessions' do
  20. expect { migrate }.to change(ActiveRecord::SessionStore::Session, :count).to(0)
  21. end
  22. end
  23. end