2019-04-24 06:50:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-08-18 05:11:27 -04:00
|
|
|
require 'fast_spec_helper'
|
2019-04-24 06:50:00 -04:00
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Gitlab::Session do
|
2019-04-24 06:50:00 -04:00
|
|
|
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
|
2022-08-01 23:09:33 -04:00
|
|
|
described_class.with_session(two: 2) {}
|
2019-04-24 06:50:00 -04:00
|
|
|
|
|
|
|
expect(described_class.current).to eq nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|