2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2015-07-07 12:52:19 +08:00
|
|
|
|
|
|
|
describe Jobs::DashboardStats do
|
|
|
|
it 'caches the stats' do
|
2016-04-21 14:45:16 +08:00
|
|
|
Timecop.freeze do
|
2016-05-18 10:42:40 +08:00
|
|
|
begin
|
|
|
|
stats = AdminDashboardData.fetch_stats.to_json
|
|
|
|
cache_key = AdminDashboardData.stats_cache_key
|
2016-04-21 14:45:16 +08:00
|
|
|
|
2016-05-18 10:42:40 +08:00
|
|
|
expect($redis.get(cache_key)).to eq(nil)
|
|
|
|
expect(described_class.new.execute({})).to eq(stats)
|
|
|
|
expect($redis.get(cache_key)).to eq(stats)
|
|
|
|
ensure
|
|
|
|
$redis.del(cache_key)
|
|
|
|
end
|
2016-04-21 14:45:16 +08:00
|
|
|
end
|
2015-07-07 12:52:19 +08:00
|
|
|
end
|
|
|
|
end
|