summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/redis/sessions_spec.rb
blob: b02864cb73d47f34b9b36a962fd1a0b5c5a603a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Redis::Sessions do
  it_behaves_like "redis_new_instance_shared_examples", 'sessions', Gitlab::Redis::SharedState

  describe 'redis instance used in connection pool' do
    around do |example|
      clear_pool
      example.run
    ensure
      clear_pool
    end

    it 'uses ::Redis instance' do
      described_class.pool.with do |redis_instance|
        expect(redis_instance).to be_instance_of(::Redis)
      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
    subject(:store) { described_class.store(namespace: described_class::SESSION_NAMESPACE) }

    # 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)
    end
  end
end