mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 09:23:39 +08:00
c9dab6fd08
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors. By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
42 lines
972 B
Ruby
42 lines
972 B
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Redis rake tasks", type: :multisite do
|
|
let(:redis) { Discourse.redis.without_namespace }
|
|
|
|
before do
|
|
Discourse::Application.load_tasks
|
|
end
|
|
|
|
describe 'clean up' do
|
|
it 'should clean up orphan Redis keys' do
|
|
active_keys = [
|
|
'__mb_backlog_id_n_/users/someusername$|$default',
|
|
'default:user-last-seen:607',
|
|
'sidekiq:something:do:something',
|
|
'somekeytonotbetouched'
|
|
]
|
|
|
|
orphan_keys = [
|
|
'tgxworld:user-last-seen:607',
|
|
'__mb_backlog_id_n_/users/someusername$|$tgxworld'
|
|
]
|
|
|
|
(active_keys | orphan_keys).each do |key|
|
|
redis.set(key, 1)
|
|
end
|
|
|
|
Rake::Task['redis:clean_up'].invoke
|
|
|
|
active_keys.each do |key|
|
|
expect(redis.get(key)).to eq('1')
|
|
end
|
|
|
|
orphan_keys.each do |key|
|
|
expect(redis.get(key)).to eq(nil)
|
|
end
|
|
ensure
|
|
active_keys.each { |key| redis.del(key) }
|
|
end
|
|
end
|
|
end
|