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:
authorReuben Pereira <rpereira@gitlab.com>2019-02-18 14:24:00 +0300
committerNick Thomas <nick@gitlab.com>2019-02-18 14:24:00 +0300
commit0e7a9e46d25813670bc9d37b59d577bda4aeb3f7 (patch)
tree717a8527bd25b8a57e1e35bac89052e88d344622 /spec/models/concerns
parent1d229689588e0e22b5cee57f6c8d2ddcc7f0822b (diff)
Allow blank values to be stored in reactive cache
Reactive caching concern was using .present? to determine if it got a valid value from the cache. This returns false for values such as false, [], {}. Change this check to !.nil? instead.
Diffstat (limited to 'spec/models/concerns')
-rw-r--r--spec/models/concerns/reactive_caching_spec.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/spec/models/concerns/reactive_caching_spec.rb b/spec/models/concerns/reactive_caching_spec.rb
index 97a4c212f1c..03ae45e6b17 100644
--- a/spec/models/concerns/reactive_caching_spec.rb
+++ b/spec/models/concerns/reactive_caching_spec.rb
@@ -25,7 +25,7 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
def result
with_reactive_cache do |data|
- data / 2
+ data
end
end
end
@@ -64,7 +64,7 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
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 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
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