2021-10-15 11:10:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Gitlab::Redis::Sessions do
|
2021-12-17 10:13:39 -05:00
|
|
|
it_behaves_like "redis_new_instance_shared_examples", 'sessions', Gitlab::Redis::SharedState
|
2021-11-24 13:14:31 -05:00
|
|
|
|
|
|
|
describe 'redis instance used in connection pool' do
|
2022-01-14 07:18:55 -05:00
|
|
|
around do |example|
|
2021-11-24 13:14:31 -05:00
|
|
|
clear_pool
|
2022-01-14 07:18:55 -05:00
|
|
|
example.run
|
|
|
|
ensure
|
2021-11-29 07:14:03 -05:00
|
|
|
clear_pool
|
|
|
|
end
|
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
it 'uses ::Redis instance' do
|
|
|
|
described_class.pool.with do |redis_instance|
|
|
|
|
expect(redis_instance).to be_instance_of(::Redis)
|
2021-11-24 13:14:31 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def clear_pool
|
|
|
|
described_class.remove_instance_variable(:@pool)
|
|
|
|
rescue NameError
|
|
|
|
# raised if @pool was not set; ignore
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#store' do
|
2021-12-17 10:13:39 -05:00
|
|
|
subject(:store) { described_class.store(namespace: described_class::SESSION_NAMESPACE) }
|
2021-11-24 13:14:31 -05:00
|
|
|
|
2022-01-14 07:18:55 -05:00
|
|
|
# Check that Gitlab::Redis::Sessions is configured as RedisStore.
|
|
|
|
it 'instantiates an instance of Redis::Store' do
|
|
|
|
expect(store).to be_instance_of(::Redis::Store)
|
2021-12-14 07:13:33 -05:00
|
|
|
end
|
2021-11-24 13:14:31 -05:00
|
|
|
end
|
2021-10-15 11:10:09 -04:00
|
|
|
end
|