diff options
Diffstat (limited to 'spec/services/groups/open_issues_count_service_spec.rb')
-rw-r--r-- | spec/services/groups/open_issues_count_service_spec.rb | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/spec/services/groups/open_issues_count_service_spec.rb b/spec/services/groups/open_issues_count_service_spec.rb index 8bbb1c90c6b..740e9846119 100644 --- a/spec/services/groups/open_issues_count_service_spec.rb +++ b/spec/services/groups/open_issues_count_service_spec.rb @@ -54,53 +54,7 @@ RSpec.describe Groups::OpenIssuesCountService, :use_clean_rails_memory_store_cac end end - context 'with different cache values' do - let(:public_count_key) { subject.cache_key(described_class::PUBLIC_COUNT_KEY) } - let(:under_threshold) { described_class::CACHED_COUNT_THRESHOLD - 1 } - let(:over_threshold) { described_class::CACHED_COUNT_THRESHOLD + 1 } - - context 'when cache is empty' do - before do - Rails.cache.delete(public_count_key) - end - - it 'refreshes cache if value over threshold' do - allow(subject).to receive(:uncached_count).and_return(over_threshold) - - expect(subject.count).to eq(over_threshold) - expect(Rails.cache.read(public_count_key)).to eq(over_threshold) - end - - it 'does not refresh cache if value under threshold' do - allow(subject).to receive(:uncached_count).and_return(under_threshold) - - expect(subject.count).to eq(under_threshold) - expect(Rails.cache.read(public_count_key)).to be_nil - end - end - - context 'when cached count is under the threshold value' do - before do - Rails.cache.write(public_count_key, under_threshold) - end - - it 'does not refresh cache' do - expect(Rails.cache).not_to receive(:write) - expect(subject.count).to eq(under_threshold) - end - end - - context 'when cached count is over the threshold value' do - before do - Rails.cache.write(public_count_key, over_threshold) - end - - it 'does not refresh cache' do - expect(Rails.cache).not_to receive(:write) - expect(subject.count).to eq(over_threshold) - end - end - end + it_behaves_like 'a counter caching service with threshold' end end end |