session_spec.rb 1.1 KB

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