Fix inactive user removal not respecting configuration for daily limits
It seems ActiveRecord ignores .limit() if .find_each() is used to iterate the query (http://stackoverflow.com/a/6680541/1489738). Using .each() instead. Added a test. closes #5953
This commit is contained in:
parent
2668c487e7
commit
aec2467e98
3 changed files with 11 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue