debian-mirror-gitlab/spec/initializers/session_store_spec.rb

50 lines
1.5 KiB
Ruby
Raw Normal View History

2021-12-11 22:18:48 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Session initializer for GitLab' do
subject { Gitlab::Application.config }
let(:load_session_store) do
load Rails.root.join('config/initializers/session_store.rb')
end
describe 'config#session_store' do
2022-01-26 12:08:38 +05:30
context 'when the GITLAB_USE_REDIS_SESSIONS_STORE env is not set' do
2021-12-11 22:18:48 +05:30
before do
2022-01-26 12:08:38 +05:30
stub_env('GITLAB_USE_REDIS_SESSIONS_STORE', nil)
2021-12-11 22:18:48 +05:30
end
2022-01-26 12:08:38 +05:30
it 'initialized with Multistore as ENV var defaults to true' do
2021-12-11 22:18:48 +05:30
expect(subject).to receive(:session_store).with(:redis_store, a_hash_including(redis_store: kind_of(::Redis::Store)))
load_session_store
end
end
2022-01-26 12:08:38 +05:30
context 'when the GITLAB_USE_REDIS_SESSIONS_STORE env is disabled' do
2021-12-11 22:18:48 +05:30
before do
2022-01-26 12:08:38 +05:30
stub_env('GITLAB_USE_REDIS_SESSIONS_STORE', false)
2021-12-11 22:18:48 +05:30
end
it 'initialized as a redis_store with a proper servers configuration' do
2022-01-26 12:08:38 +05:30
expect(subject).to receive(:session_store).with(:redis_store, a_hash_including(redis_store: kind_of(Redis::Store)))
load_session_store
end
end
context 'when the GITLAB_USE_REDIS_SESSIONS_STORE env is enabled' do
before do
stub_env('GITLAB_USE_REDIS_SESSIONS_STORE', true)
end
it 'initialized as a redis_store with a proper servers configuration' do
expect(subject).to receive(:session_store).with(:redis_store, a_hash_including(redis_store: kind_of(::Redis::Store)))
2021-12-11 22:18:48 +05:30
load_session_store
end
end
end
end