mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 05:02:44 +08:00
DEV: Stop leaking state in dashboard controller specs (#19608)
A few specs in `dashboard_controller_spec.rb` set some state in redis but don't clean it up afterwards which causes other specs to fail when they're ran after `dashboard_controller_spec.rb`.
Related commit: 18467d4
.
This commit is contained in:
parent
953b823c5a
commit
d8b39810d2
|
@ -186,6 +186,21 @@ module DiscourseUpdates
|
||||||
Discourse.redis.hset(last_viewed_feature_dates_for_users_key, user_id.to_s, feature_date)
|
Discourse.redis.hset(last_viewed_feature_dates_for_users_key, user_id.to_s, feature_date)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clean_state
|
||||||
|
Discourse.redis.del(
|
||||||
|
last_installed_version_key,
|
||||||
|
latest_version_key,
|
||||||
|
critical_updates_available_key,
|
||||||
|
missing_versions_count_key,
|
||||||
|
updated_at_key,
|
||||||
|
missing_versions_list_key,
|
||||||
|
new_features_key,
|
||||||
|
last_viewed_feature_dates_for_users_key,
|
||||||
|
*Discourse.redis.keys("#{missing_versions_key_prefix}*"),
|
||||||
|
*Discourse.redis.keys(new_features_last_seen_key("*")),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def last_installed_version_key
|
def last_installed_version_key
|
||||||
|
|
|
@ -60,8 +60,7 @@ RSpec.describe Jobs::CheckNewFeatures do
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Discourse.redis.del("new_features")
|
DiscourseUpdates.clean_state
|
||||||
Discourse.redis.del("last_viewed_feature_dates_for_users_hash")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "backfills last viewed feature for admins who don't have last viewed feature" do
|
it "backfills last viewed feature for admins who don't have last viewed feature" do
|
||||||
|
|
|
@ -155,7 +155,7 @@ RSpec.describe DiscourseUpdates do
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
Discourse.redis.del('new_features')
|
DiscourseUpdates.clean_state
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns all items on the first run' do
|
it 'returns all items on the first run' do
|
||||||
|
|
|
@ -172,12 +172,13 @@ RSpec.describe Admin::DashboardController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#new_features' do
|
describe '#new_features' do
|
||||||
|
after do
|
||||||
|
DiscourseUpdates.clean_state
|
||||||
|
end
|
||||||
|
|
||||||
context "when logged in as an admin" do
|
context "when logged in as an admin" do
|
||||||
before do
|
before do
|
||||||
sign_in(admin)
|
sign_in(admin)
|
||||||
Discourse.redis.del "new_features_last_seen_user_#{admin.id}"
|
|
||||||
Discourse.redis.del "new_features"
|
|
||||||
Discourse.redis.del "last_viewed_feature_dates_for_users_hash"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'is empty by default' do
|
it 'is empty by default' do
|
||||||
|
@ -284,6 +285,10 @@ RSpec.describe Admin::DashboardController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#mark_new_features_as_seen' do
|
describe '#mark_new_features_as_seen' do
|
||||||
|
after do
|
||||||
|
DiscourseUpdates.clean_state
|
||||||
|
end
|
||||||
|
|
||||||
context "when logged in as an admin" do
|
context "when logged in as an admin" do
|
||||||
before { sign_in(admin) }
|
before { sign_in(admin) }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user