discourse/spec/support/shared_examples_for_stats_cacheable.rb

29 lines
835 B
Ruby
Raw Normal View History

# frozen_string_literal: true
shared_examples_for 'stats cacheable' do
2015-07-06 23:52:19 -05:00
describe 'fetch_cached_stats' do
after do
Discourse.redis.del(described_class.stats_cache_key)
end
2015-07-06 23:52:19 -05:00
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))
2015-07-06 23:52:19 -05:00
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))
2015-07-06 23:52:19 -05:00
end
end
describe 'fetch_stats' do
it 'has not been implemented' do
2017-07-27 20:20:09 -05:00
expect { described_class.fetch_stats }.to_not raise_error
2015-07-06 23:52:19 -05:00
end
end
end