Project

General

Profile

Feature #30998 » 30998-v2.patch

Go MAEDA, 2021-06-30 17:04

View differences:

app/models/user.rb
887 887
    project_ids.map(&:to_i)
888 888
  end
889 889

  
890
  def self.prune(age=7.days)
891
    User.where("created_on < ? AND status = ?", Time.now - age, STATUS_REGISTERED).destroy_all
892
  end
893

  
890 894
  protected
891 895

  
892 896
  def validate_password_length
lib/tasks/redmine.rake
40 40
    end
41 41
  end
42 42

  
43
  namespace :users do
44
    desc 'Removes registered users that have not been activated after seven days.'
45
    task :prune => :environment do
46
      User.prune
47
    end
48
  end
49

  
43 50
  namespace :watchers do
44 51
    desc 'Removes watchers from what they can no longer view.'
45 52
    task :prune => :environment do
test/unit/user_test.rb
1313 1313
    assert_equal [], User.find(2).bookmarked_project_ids
1314 1314
  end
1315 1315

  
1316
  def test_prune_should_destroy_not_activated_old_users
1317
    User.generate!(:status => User::STATUS_REGISTERED, :created_on => 8.days.ago)
1318
    User.generate!(:status => User::STATUS_REGISTERED, :created_on => 7.days.ago)
1319
    User.generate!(:status => User::STATUS_REGISTERED, :created_on => 6.days.ago)
1320

  
1321
    assert_difference 'User.count', -2 do
1322
      User.prune
1323
    end
1324
  end
1325

  
1316 1326
  if Object.const_defined?(:OpenID)
1317 1327
    def test_setting_identity_url
1318 1328
      normalized_open_id_url = 'http://example.com/'
(2-2/4)