diff options
author | Stan Hu <stanhu@gmail.com> | 2018-12-18 02:51:28 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-12-18 02:51:28 +0300 |
commit | 18c78901bc49055bbfea44f4800e073847a89ad2 (patch) | |
tree | decac064c509351df5cbe07eccbe7c754ed1b559 | |
parent | 41b4f9fef62096e3191e0013efd216c756d7abb9 (diff) | |
parent | 279be8aaa28a1f5c6e6e8601eb0df579cbaf1eeb (diff) |
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
-rw-r--r-- | lib/gitlab/safe_request_store.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/safe_request_store_spec.rb | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/gitlab/safe_request_store.rb b/lib/gitlab/safe_request_store.rb index 4e82353adb6..d146913bdb3 100644 --- a/lib/gitlab/safe_request_store.rb +++ b/lib/gitlab/safe_request_store.rb @@ -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 diff --git a/spec/lib/gitlab/safe_request_store_spec.rb b/spec/lib/gitlab/safe_request_store_spec.rb index c797171dbe2..bae87e43615 100644 --- a/spec/lib/gitlab/safe_request_store_spec.rb +++ b/spec/lib/gitlab/safe_request_store_spec.rb @@ -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 |