diff --git a/Changelog.md b/Changelog.md index d1013d3c9..36235613c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -24,6 +24,7 @@ * Use correct branding in Atom feed [#5929](https://github.com/diaspora/diaspora/pull/5929) * Update the configurate gem to avoid issues by missed missing settings keys [#5934](https://github.com/diaspora/diaspora/pull/5934) * ContactPresenter#full_hash_with_person did not contain relationship information [#5936](https://github.com/diaspora/diaspora/pull/5936) +* Fix inactive user removal not respecting configuration for daily limits [#5953](https://github.com/diaspora/diaspora/pull/5953) ## Features * Hide post title of limited post in comment notification email [#5843](https://github.com/diaspora/diaspora/pull/5843) diff --git a/app/workers/queue_users_for_removal.rb b/app/workers/queue_users_for_removal.rb index 6d98837d6..b9565f7a8 100644 --- a/app/workers/queue_users_for_removal.rb +++ b/app/workers/queue_users_for_removal.rb @@ -22,7 +22,7 @@ module Workers # and queue accounts for closing to sidekiq # for those who have not signed in, skip warning and queue removal # in +1 days - users.find_each do |user| + users.each do |user| if user.sign_in_count > 0 remove_at = Time.now + AppConfig.settings.maintenance.remove_old_users.warn_days.to_i.days else @@ -38,4 +38,4 @@ module Workers end end end -end \ No newline at end of file +end diff --git a/spec/workers/queue_users_for_removal_spec.rb b/spec/workers/queue_users_for_removal_spec.rb index 6e00fe76c..e7871ccad 100644 --- a/spec/workers/queue_users_for_removal_spec.rb +++ b/spec/workers/queue_users_for_removal_spec.rb @@ -4,6 +4,7 @@ describe Workers::QueueUsersForRemoval do describe 'remove_old_users is active' do before do AppConfig.settings.maintenance.remove_old_users.enable = true + AppConfig.settings.maintenance.remove_old_users.limit_removals_to_per_day = 1 ActionMailer::Base.deliveries = nil Timecop.freeze end @@ -50,6 +51,13 @@ describe Workers::QueueUsersForRemoval do expect(user.remove_after).to eq(removal_date) expect(ActionMailer::Base.deliveries.count).to eq(0) end + + it '#does not queue more warnings than has been configured as limit' do + FactoryGirl.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 1) + FactoryGirl.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 1) + Workers::QueueUsersForRemoval.new.perform + expect(ActionMailer::Base.deliveries.count).to eq(1) + end after do Timecop.return