Commit 18c78901 authored by Stan Hu's avatar Stan Hu

Merge branch '8765-geo-gitlab-geo-should-not-serialize-activerecord-objects' into 'master'

Change SafeRequestStore#write to accept an options hash

See merge request gitlab-org/gitlab-ce!23891
parents 41b4f9fe 279be8aa
...@@ -19,5 +19,13 @@ module Gitlab ...@@ -19,5 +19,13 @@ module Gitlab
NULL_STORE NULL_STORE
end end
end end
# This method accept an options hash to be compatible with
# ActiveSupport::Cache::Store#write method. The options are
# not passed to the underlying cache implementation because
# RequestStore#write accepts only a key, and value params.
def self.write(key, value, options = nil)
store.write(key, value)
end
end end
end end
...@@ -78,6 +78,12 @@ describe Gitlab::SafeRequestStore do ...@@ -78,6 +78,12 @@ describe Gitlab::SafeRequestStore do
described_class.write('foo', true) described_class.write('foo', true)
end.to change { described_class.read('foo') }.from(nil).to(true) end.to change { described_class.read('foo') }.from(nil).to(true)
end end
it 'does not pass the options hash to the underlying store implementation' do
expect(described_class.store).to receive(:write).with('foo', true)
described_class.write('foo', true, expires_in: 15.seconds)
end
end end
context 'when RequestStore is NOT active' do context 'when RequestStore is NOT active' do
...@@ -86,6 +92,12 @@ describe Gitlab::SafeRequestStore do ...@@ -86,6 +92,12 @@ describe Gitlab::SafeRequestStore do
described_class.write('foo', true) described_class.write('foo', true)
end.not_to change { described_class.read('foo') }.from(nil) end.not_to change { described_class.read('foo') }.from(nil)
end end
it 'does not pass the options hash to the underlying store implementation' do
expect(described_class.store).to receive(:write).with('foo', true)
described_class.write('foo', true, expires_in: 15.seconds)
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment