2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2021-05-20 06:59:02 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe Session, type: :model do
|
|
|
|
|
|
|
|
describe 'Check that session creation' do
|
|
|
|
context 'without persistent flag in data payload' do
|
2021-07-16 13:38:01 +00:00
|
|
|
subject(:session) { described_class.create(session_id: SecureRandom.urlsafe_base64(64), data: {}) }
|
2021-05-20 06:59:02 +00:00
|
|
|
|
|
|
|
it 'does not set the persistent attribute' do
|
2021-07-16 13:29:38 +00:00
|
|
|
expect(session.persistent).to be_nil
|
2021-05-20 06:59:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with true persistent flag in data payload' do
|
2021-07-16 13:38:01 +00:00
|
|
|
subject(:session) { described_class.create(session_id: SecureRandom.urlsafe_base64(64), data: { 'persistent' => true }) }
|
2021-05-20 06:59:02 +00:00
|
|
|
|
|
|
|
it 'sets the persistent attribute in the session and removes the persistent attribute from the data payload' do
|
|
|
|
expect(session.persistent).to eq(true)
|
|
|
|
expect(session.persistent).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with false persistent flag in data payload' do
|
2021-07-16 13:38:01 +00:00
|
|
|
subject(:session) { described_class.create(session_id: SecureRandom.urlsafe_base64(64), data: { 'persistent' => false }) }
|
2021-05-20 06:59:02 +00:00
|
|
|
|
|
|
|
it 'does not set the persistent attribute' do
|
2021-07-16 13:29:38 +00:00
|
|
|
expect(session.persistent).to be_nil
|
2021-05-20 06:59:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|