Files
discourse/spec/support/shared_examples_for_stats_cacheable.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
845 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2022-07-28 05:27:38 +03:00
RSpec.shared_examples_for "stats cacheable" do
2015-07-07 12:52:19 +08:00
describe "fetch_cached_stats" do
2019-12-03 10:05:53 +01:00
after { Discourse.redis.del(described_class.stats_cache_key) }
2016-04-21 14:45:16 +08:00
2015-07-07 12:52:19 +08:00
it "returns the cached stats" do
2016-04-21 14:45:16 +08:00
stats = described_class.fetch_stats.to_json
2019-12-03 10:05:53 +01:00
Discourse.redis.set(described_class.stats_cache_key, stats)
2016-04-21 14:45:16 +08:00
expect(described_class.fetch_cached_stats).to eq(JSON.parse(stats))
2015-07-07 12:52:19 +08:00
end
2016-04-21 14:45:16 +08:00
it "returns fetches the stats if stats has not been cached" do
2017-07-24 09:17:42 -04:00
freeze_time
2019-12-03 10:05:53 +01:00
Discourse.redis.del(described_class.stats_cache_key)
2017-07-24 09:17:42 -04:00
expect(described_class.fetch_cached_stats).to eq(
JSON.parse(described_class.fetch_stats.to_json),
)
2015-07-07 12:52:19 +08:00
end
end
describe "fetch_stats" do
2016-04-21 14:45:16 +08:00
it "has not been implemented" do
2015-07-07 12:52:19 +08:00
expect { described_class.fetch_stats }.to_not raise_error
end
end
end