summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/session_spec.rb
blob: de680e8425e7390361dbf4f58146be133a5108d2 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Session do
  it 'uses the current thread as a data store' do
    Thread.current[:session_storage] = { a: :b }

    expect(described_class.current).to eq(a: :b)
  ensure
    Thread.current[:session_storage] = nil
  end

  describe '#with_session' do
    it 'sets session hash' do
      described_class.with_session(one: 1) do
        expect(described_class.current).to eq(one: 1)
      end
    end

    it 'restores current store after' do
      described_class.with_session(two: 2) { }

      expect(described_class.current).to eq nil
    end
  end
end