Commit 418e390d authored by Nick Thomas's avatar Nick Thomas
Browse files

Merge branch '56851-blank-values-in-reactive-cache' into 'master'

Allow blank values to be stored in reactive cache

See merge request gitlab-org/gitlab-ce!25283
parents 1d229689 0e7a9e46
......@@ -76,7 +76,7 @@ def with_reactive_cache(*args, &blk)
begin
data = Rails.cache.read(full_reactive_cache_key(*args))
yield data if data.present?
yield data unless data.nil?
rescue InvalidateReactiveCache
refresh_reactive_cache!(*args)
nil
......
---
title: Allow empty values such as [] to be stored in reactive cache
merge_request: 25283
author:
type: fixed
......@@ -25,7 +25,7 @@ def calculate_reactive_cache
def result
with_reactive_cache do |data|
data / 2
data
end
end
end
......@@ -64,7 +64,7 @@ def result
stub_reactive_cache(instance, 4)
end
it { is_expected.to eq(2) }
it { is_expected.to eq(4) }
it 'does not enqueue a background worker' do
expect(ReactiveCachingWorker).not_to receive(:perform_async)
......@@ -94,6 +94,14 @@ def result
end
end
end
context 'when cache contains non-nil but blank value' do
before do
stub_reactive_cache(instance, false)
end
it { is_expected.to eq(false) }
end
end
describe '#clear_reactive_cache!' do
......
......@@ -10,7 +10,7 @@ def alive_reactive_cache_key(subject, *qualifiers)
def stub_reactive_cache(subject = nil, data = nil, *qualifiers)
allow(ReactiveCachingWorker).to receive(:perform_async)
allow(ReactiveCachingWorker).to receive(:perform_in)
write_reactive_cache(subject, data, *qualifiers) if data
write_reactive_cache(subject, data, *qualifiers) unless data.nil?
end
def synchronous_reactive_cache(subject)
......
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