2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
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
|
|
|
|
subject(:session) { described_class.create( session_id: SecureRandom.urlsafe_base64(64), data: {} ) }
|
|
|
|
|
|
|
|
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
|
|
|
|
subject(:session) { described_class.create( session_id: SecureRandom.urlsafe_base64(64), data: { 'persistent' => true }) }
|
|
|
|
|
|
|
|
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
|
|
|
|
subject(:session) { described_class.create( session_id: SecureRandom.urlsafe_base64(64), data: { 'persistent' => false }) }
|
|
|
|
|
|
|
|
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
|