Merge pull request #5428 from discourse/fix-pending-users-count

FIX: incorrect pending_users_reminder user count
This commit is contained in:
Neil Lalonde 2017-12-14 14:05:37 -05:00 committed by GitHub
commit 3cbaea81bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -22,13 +22,13 @@ module Jobs
target_usernames = Group[:moderators].users.map do |user|
next if user.id < 0
count = user.notifications.joins(:topic)
unseen_count = user.notifications.joins(:topic)
.where("notifications.id > ?", user.seen_notification_id)
.where("notifications.read = false")
.where("topics.subtype = ?", TopicSubtype.pending_users_reminder)
.count
count == 0 ? user.username : nil
unseen_count == 0 ? user.username : nil
end.compact
unless target_usernames.empty?

View File

@ -38,6 +38,13 @@ describe Jobs::PendingUsersReminder do
PostCreator.expects(:create).never
Jobs::PendingUsersReminder.new.execute({})
end
it "sets the correct pending user count in the notification" do
SiteSetting.pending_users_reminder_delay = 8
Fabricate(:user, created_at: 9.hours.ago)
PostCreator.expects(:create).with(Discourse.system_user, has_entries(title: '1 user waiting for approval'))
Jobs::PendingUsersReminder.new.execute({})
end
end
end