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)
|
* 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)
|
* 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)
|
* 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
|
## Features
|
||||||
* Hide post title of limited post in comment notification email [#5843](https://github.com/diaspora/diaspora/pull/5843)
|
* 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
|
# and queue accounts for closing to sidekiq
|
||||||
# for those who have not signed in, skip warning and queue removal
|
# for those who have not signed in, skip warning and queue removal
|
||||||
# in +1 days
|
# in +1 days
|
||||||
users.find_each do |user|
|
users.each do |user|
|
||||||
if user.sign_in_count > 0
|
if user.sign_in_count > 0
|
||||||
remove_at = Time.now + AppConfig.settings.maintenance.remove_old_users.warn_days.to_i.days
|
remove_at = Time.now + AppConfig.settings.maintenance.remove_old_users.warn_days.to_i.days
|
||||||
else
|
else
|
||||||
|
|
@ -38,4 +38,4 @@ module Workers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ describe Workers::QueueUsersForRemoval do
|
||||||
describe 'remove_old_users is active' do
|
describe 'remove_old_users is active' do
|
||||||
before do
|
before do
|
||||||
AppConfig.settings.maintenance.remove_old_users.enable = true
|
AppConfig.settings.maintenance.remove_old_users.enable = true
|
||||||
|
AppConfig.settings.maintenance.remove_old_users.limit_removals_to_per_day = 1
|
||||||
ActionMailer::Base.deliveries = nil
|
ActionMailer::Base.deliveries = nil
|
||||||
Timecop.freeze
|
Timecop.freeze
|
||||||
end
|
end
|
||||||
|
|
@ -50,6 +51,13 @@ describe Workers::QueueUsersForRemoval do
|
||||||
expect(user.remove_after).to eq(removal_date)
|
expect(user.remove_after).to eq(removal_date)
|
||||||
expect(ActionMailer::Base.deliveries.count).to eq(0)
|
expect(ActionMailer::Base.deliveries.count).to eq(0)
|
||||||
end
|
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
|
after do
|
||||||
Timecop.return
|
Timecop.return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue