mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 23:16:32 +08:00
FIX: Don't try to delete inactive admins
This commit is contained in:
parent
422237391e
commit
6d77156a94
@ -9,7 +9,7 @@ module Jobs
|
|||||||
destroyer = UserDestroyer.new(Discourse.system_user)
|
destroyer = UserDestroyer.new(Discourse.system_user)
|
||||||
|
|
||||||
User.joins("LEFT JOIN posts ON posts.user_id = users.id")
|
User.joins("LEFT JOIN posts ON posts.user_id = users.id")
|
||||||
.where(last_posted_at: nil, trust_level: TrustLevel.levels[:newuser])
|
.where(last_posted_at: nil, trust_level: TrustLevel.levels[:newuser], admin: false)
|
||||||
.where(
|
.where(
|
||||||
"posts.user_id IS NULL AND users.last_seen_at < ?",
|
"posts.user_id IS NULL AND users.last_seen_at < ?",
|
||||||
SiteSetting.clean_up_inactive_users_after_days.days.ago
|
SiteSetting.clean_up_inactive_users_after_days.days.ago
|
||||||
|
@ -32,4 +32,12 @@ RSpec.describe Jobs::CleanUpInactiveUsers do
|
|||||||
|
|
||||||
expect(User.exists?(id: user.id)).to eq(false)
|
expect(User.exists?(id: user.id)).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't delete inactive admins" do
|
||||||
|
SiteSetting.clean_up_inactive_users_after_days = 4
|
||||||
|
admin = Fabricate(:admin, last_seen_at: 5.days.ago, trust_level: TrustLevel.levels[:newuser])
|
||||||
|
|
||||||
|
expect { described_class.new.execute({}) }.to_not change { User.count }
|
||||||
|
expect(User.exists?(admin.id)).to eq(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user