diff options
author | Dennis Tang <dtang@gitlab.com> | 2018-05-11 18:42:20 +0200 |
---|---|---|
committer | Dennis Tang <dtang@gitlab.com> | 2018-05-11 18:42:20 +0200 |
commit | 2205ed4f07265a43d2561ab2657557e317e7b9c0 (patch) | |
tree | 08e8373f874b59e78d97dd87b1c687d3458823d9 /spec/models/concerns/reactive_caching_spec.rb | |
parent | 3a3f4a348be936abde6881fc3909026932bf97ab (diff) | |
parent | f4e234d92a2ff31dc681d56b52e9fbbbe3f931b1 (diff) | |
download | gitlab-ce-2205ed4f07265a43d2561ab2657557e317e7b9c0.tar.gz |
Merge remote-tracking branch 'origin/master' into 38759-fetch-available-parameters-directly-from-gke-when-creating-a-cluster
Diffstat (limited to 'spec/models/concerns/reactive_caching_spec.rb')
-rw-r--r-- | spec/models/concerns/reactive_caching_spec.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/spec/models/concerns/reactive_caching_spec.rb b/spec/models/concerns/reactive_caching_spec.rb index a5d505af001..4570dbb1d8e 100644 --- a/spec/models/concerns/reactive_caching_spec.rb +++ b/spec/models/concerns/reactive_caching_spec.rb @@ -29,12 +29,6 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do end end - let(:now) { Time.now.utc } - - around do |example| - Timecop.freeze(now) { example.run } - end - let(:calculation) { -> { 2 + 2 } } let(:cache_key) { "foo:666" } let(:instance) { CacheTest.new(666, &calculation) } @@ -49,13 +43,15 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do context 'when cache is empty' do it { is_expected.to be_nil } - it 'queues a background worker' do + it 'enqueues a background worker to bootstrap the cache' do expect(ReactiveCachingWorker).to receive(:perform_async).with(CacheTest, 666) go! end it 'updates the cache lifespan' do + expect(reactive_cache_alive?(instance)).to be_falsy + go! expect(reactive_cache_alive?(instance)).to be_truthy @@ -69,6 +65,18 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do it { is_expected.to eq(2) } + it 'does not enqueue a background worker' do + expect(ReactiveCachingWorker).not_to receive(:perform_async) + + go! + end + + it 'updates the cache lifespan' do + expect(Rails.cache).to receive(:write).with(alive_reactive_cache_key(instance), true, expires_in: anything) + + go! + end + context 'and expired' do before do invalidate_reactive_cache(instance) |