mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Cache About#stats.
This commit is contained in:
23
spec/support/shared_examples_for_stats_cacheable.rb
Normal file
23
spec/support/shared_examples_for_stats_cacheable.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
shared_examples_for 'stats cachable' do
|
||||
describe 'fetch_cached_stats' do
|
||||
it 'returns the cached stats' do
|
||||
begin
|
||||
stats = { "visits" => 10 }
|
||||
$redis.set(described_class.stats_cache_key, stats.to_json)
|
||||
expect(described_class.fetch_cached_stats).to eq(stats)
|
||||
ensure
|
||||
$redis.del(described_class.stats_cache_key)
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns nil if no stats has been cached' do
|
||||
expect(described_class.fetch_cached_stats).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'fetch_stats' do
|
||||
it 'has been implemented' do
|
||||
expect{ described_class.fetch_stats }.to_not raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user