mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 13:15:48 +08:00
4020c87680
* Remove use of 0 in favor of `TrustLevel.levels[:newuser]`. * Consolidate two tests into a single one. * Test that disabling the feature works. * Avoid loading full ActiveRecord object in test when we only need to know the existence of the record.
36 lines
914 B
Ruby
36 lines
914 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Jobs::CleanUpInactiveUsers do
|
|
it "should clean up new users that have been inactive" do
|
|
SiteSetting.clean_up_inactive_users_after_days = 0
|
|
|
|
user = Fabricate(:user,
|
|
last_seen_at: 5.days.ago,
|
|
trust_level: TrustLevel.levels[:newuser]
|
|
)
|
|
|
|
Fabricate(:active_user)
|
|
|
|
Fabricate(:post, user: Fabricate(:user,
|
|
trust_level: TrustLevel.levels[:newuser],
|
|
last_seen_at: 5.days.ago
|
|
)).user
|
|
|
|
Fabricate(:user,
|
|
trust_level: TrustLevel.levels[:newuser],
|
|
last_seen_at: 2.days.ago
|
|
)
|
|
|
|
Fabricate(:user, trust_level: TrustLevel.levels[:basic])
|
|
|
|
expect { described_class.new.execute({}) }.to_not change { User.count }
|
|
|
|
SiteSetting.clean_up_inactive_users_after_days = 4
|
|
|
|
expect { described_class.new.execute({}) }
|
|
.to change { User.count }.by(-1)
|
|
|
|
expect(User.exists?(id: user.id)).to eq(false)
|
|
end
|
|
end
|