discourse/spec/support/shared_examples_for_stats_cacheable.rb
Josh Soref 59097b207f
DEV: Correct typos and spelling mistakes (#12812)
Over the years we accrued many spelling mistakes in the code base. 

This PR attempts to fix spelling mistakes and typos in all areas of the code that are extremely safe to change 

- comments
- test descriptions
- other low risk areas
2021-05-21 11:43:47 +10:00

29 lines
835 B
Ruby

# frozen_string_literal: true
shared_examples_for 'stats cacheable' do
describe 'fetch_cached_stats' do
after do
Discourse.redis.del(described_class.stats_cache_key)
end
it 'returns the cached stats' do
stats = described_class.fetch_stats.to_json
Discourse.redis.set(described_class.stats_cache_key, stats)
expect(described_class.fetch_cached_stats).to eq(JSON.parse(stats))
end
it 'returns fetches the stats if stats has not been cached' do
freeze_time
Discourse.redis.del(described_class.stats_cache_key)
expect(described_class.fetch_cached_stats).to eq(JSON.parse(described_class.fetch_stats.to_json))
end
end
describe 'fetch_stats' do
it 'has not been implemented' do
expect { described_class.fetch_stats }.to_not raise_error
end
end
end