discourse/spec/support/shared_examples_for_stats_cacheable.rb
Sam Saffron 4ea21fa2d0 DEV: use #frozen_string_literal: true on all spec
This change both speeds up specs (less strings to allocate) and helps catch
cases where methods in Discourse are mutating inputs.

Overall we will be migrating everything to use #frozen_string_literal: true
it will take a while, but this is the first and safest move in this direction
2019-04-30 10:27:42 +10:00

29 lines
807 B
Ruby

# frozen_string_literal: true
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