Merge pull request #5428 from discourse/fix-pending-users-count
FIX: incorrect pending_users_reminder user count
This commit is contained in:
commit
3cbaea81bd
|
@ -22,13 +22,13 @@ module Jobs
|
||||||
target_usernames = Group[:moderators].users.map do |user|
|
target_usernames = Group[:moderators].users.map do |user|
|
||||||
next if user.id < 0
|
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.id > ?", user.seen_notification_id)
|
||||||
.where("notifications.read = false")
|
.where("notifications.read = false")
|
||||||
.where("topics.subtype = ?", TopicSubtype.pending_users_reminder)
|
.where("topics.subtype = ?", TopicSubtype.pending_users_reminder)
|
||||||
.count
|
.count
|
||||||
|
|
||||||
count == 0 ? user.username : nil
|
unseen_count == 0 ? user.username : nil
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
unless target_usernames.empty?
|
unless target_usernames.empty?
|
||||||
|
|
|
@ -38,6 +38,13 @@ describe Jobs::PendingUsersReminder do
|
||||||
PostCreator.expects(:create).never
|
PostCreator.expects(:create).never
|
||||||
Jobs::PendingUsersReminder.new.execute({})
|
Jobs::PendingUsersReminder.new.execute({})
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue