gitlab-org--gitlab-foss/spec/lib/gitlab/session_spec.rb
James Edwards-Jones 5faa98f481 Session stored globally per request
- This can be accessed with Session.current and is restored after.
- Data can be stored under a key with NamespacedSessionStore
2019-05-02 12:28:26 +07:00

27 lines
624 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
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