mirror of
https://github.com/discourse/discourse.git
synced 2024-11-29 04:03:57 -06:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
29 lines
841 B
Ruby
29 lines
841 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.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
|