Change SafeRequestStore#write to accept an options hash

This change the write to accept an options hash to make
it compatible with ActiveSupport::Cache::Store#write method.

The options hash are not passed to the underlying cache
implementation because RequestStore#write accepts only
a key, and value params.
parent f515c25f
......@@ -19,5 +19,13 @@ module Gitlab
NULL_STORE
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
......@@ -78,6 +78,12 @@ describe Gitlab::SafeRequestStore do
described_class.write('foo', true)
end.to change { described_class.read('foo') }.from(nil).to(true)
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
context 'when RequestStore is NOT active' do
......@@ -86,6 +92,12 @@ describe Gitlab::SafeRequestStore do
described_class.write('foo', true)
end.not_to change { described_class.read('foo') }.from(nil)
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
......
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