diff --git a/spec/jobs/about_stats_spec.rb b/spec/jobs/about_stats_spec.rb index 85a1020e6df..312b345db0f 100644 --- a/spec/jobs/about_stats_spec.rb +++ b/spec/jobs/about_stats_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' describe Jobs::AboutStats do - after do - $redis.flushall - end - it 'caches the stats' do - stats = About.fetch_stats.to_json - cache_key = About.stats_cache_key + begin + stats = About.fetch_stats.to_json + cache_key = About.stats_cache_key - expect($redis.get(cache_key)).to eq(nil) - expect(described_class.new.execute({})).to eq(stats) - expect($redis.get(cache_key)).to eq(stats) + expect($redis.get(cache_key)).to eq(nil) + expect(described_class.new.execute({})).to eq(stats) + expect($redis.get(cache_key)).to eq(stats) + ensure + $redis.del(cache_key) + end end end diff --git a/spec/jobs/dashboard_stats_spec.rb b/spec/jobs/dashboard_stats_spec.rb index 82ff12edc67..1a325f62ee3 100644 --- a/spec/jobs/dashboard_stats_spec.rb +++ b/spec/jobs/dashboard_stats_spec.rb @@ -1,18 +1,18 @@ require 'rails_helper' describe Jobs::DashboardStats do - after do - $redis.flushall - end - it 'caches the stats' do Timecop.freeze do - stats = AdminDashboardData.fetch_stats.to_json - cache_key = AdminDashboardData.stats_cache_key + begin + stats = AdminDashboardData.fetch_stats.to_json + cache_key = AdminDashboardData.stats_cache_key - expect($redis.get(cache_key)).to eq(nil) - expect(described_class.new.execute({})).to eq(stats) - expect($redis.get(cache_key)).to eq(stats) + expect($redis.get(cache_key)).to eq(nil) + expect(described_class.new.execute({})).to eq(stats) + expect($redis.get(cache_key)).to eq(stats) + ensure + $redis.del(cache_key) + end end end end diff --git a/spec/jobs/poll_mailbox_spec.rb b/spec/jobs/poll_mailbox_spec.rb index 7394556d2a8..10566133ea1 100644 --- a/spec/jobs/poll_mailbox_spec.rb +++ b/spec/jobs/poll_mailbox_spec.rb @@ -31,7 +31,7 @@ describe Jobs::PollMailbox do end after do - $redis.flushall + $redis.del(Jobs::PollMailbox::POLL_MAILBOX_TIMEOUT_ERROR_KEY) end it "add an admin dashboard message on pop authentication error" do diff --git a/spec/support/shared_examples_for_stats_cacheable.rb b/spec/support/shared_examples_for_stats_cacheable.rb index b6a2b4dfef2..decaf1f78d5 100644 --- a/spec/support/shared_examples_for_stats_cacheable.rb +++ b/spec/support/shared_examples_for_stats_cacheable.rb @@ -1,7 +1,7 @@ shared_examples_for 'stats cachable' do describe 'fetch_cached_stats' do after do - $redis.flushall + $redis.del(described_class.stats_cache_key) end it 'returns the cached stats' do