session_spec.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Session, type: :model do
  4. describe 'Check that session creation' do
  5. context 'without persistent flag in data payload' do
  6. subject(:session) { described_class.create(session_id: SecureRandom.urlsafe_base64(64), data: {}) }
  7. it 'does not set the persistent attribute' do
  8. expect(session.persistent).to be_nil
  9. end
  10. end
  11. context 'with true persistent flag in data payload' do
  12. subject(:session) { described_class.create(session_id: SecureRandom.urlsafe_base64(64), data: { 'persistent' => true }) }
  13. it 'sets the persistent attribute in the session and removes the persistent attribute from the data payload' do
  14. expect(session.persistent).to be(true)
  15. expect(session.persistent).to be(true)
  16. end
  17. end
  18. context 'with false persistent flag in data payload' do
  19. subject(:session) { described_class.create(session_id: SecureRandom.urlsafe_base64(64), data: { 'persistent' => false }) }
  20. it 'does not set the persistent attribute' do
  21. expect(session.persistent).to be_nil
  22. end
  23. end
  24. end
  25. end