Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2019-04-24 13:50:00 +0300
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2019-05-02 08:28:26 +0300
commit5faa98f481e0f5e0ccb1758c34a104f523ab21d2 (patch)
tree3119efc05e2ecc91cc0d91217c0869b69f656ea6 /spec/lib/gitlab/namespaced_session_store_spec.rb
parent0f863c68bb8bc5054a22e0c553a933c83bea4df6 (diff)
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
Diffstat (limited to 'spec/lib/gitlab/namespaced_session_store_spec.rb')
-rw-r--r--spec/lib/gitlab/namespaced_session_store_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/lib/gitlab/namespaced_session_store_spec.rb b/spec/lib/gitlab/namespaced_session_store_spec.rb
new file mode 100644
index 00000000000..c0af2ede32a
--- /dev/null
+++ b/spec/lib/gitlab/namespaced_session_store_spec.rb
@@ -0,0 +1,22 @@
+# 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