mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
We should only have one way of mocking time, misuse of timecop was causing build stability issues
27 lines
775 B
Ruby
27 lines
775 B
Ruby
shared_examples_for 'stats cachable' do
|
|
describe 'fetch_cached_stats' do
|
|
after do
|
|
$redis.del(described_class.stats_cache_key)
|
|
end
|
|
|
|
it 'returns the cached stats' do
|
|
stats = described_class.fetch_stats.to_json
|
|
$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
|
|
|
|
$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
|