gitlab-org--gitlab-foss/spec/lib/gitlab/namespaced_session_store_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

22 lines
543 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::NamespacedSessionStore do
let(:key) { :some_key }
subject { described_class.new(key) }
it 'stores data under the specified key' do
Gitlab::Session.with_session({}) do
subject[:new_data] = 123
expect(Thread.current[:session_storage][key]).to eq(new_data: 123)
end
end
it 'retrieves data from the given key' do
Thread.current[:session_storage] = { key => { existing_data: 123 } }
expect(subject[:existing_data]).to eq 123
end
end