Skip to content
Browse files

FIX: user directory should not include unapproved users

When the "must approve users" setting is enabled, new users who were
waiting to be approved could show up in the user directory.
  • Loading branch information...
nlalonde committed Sep 11, 2019
1 parent 59f7c92 commit 7331e0865ad72bbdd4d7d9d17c818a64acd41deb
Showing with 14 additions and 1 deletion.
  1. +2 −1 app/models/directory_item.rb
  2. +12 −0 spec/models/directory_item_spec.rb
@@ -65,7 +65,8 @@ def self.refresh_period!(period_type, force: false)
FROM users u
LEFT JOIN directory_items di ON di.user_id = AND di.period_type = :period_type
WHERE IS NULL AND > 0 AND u.silenced_till IS NULL and
WHERE IS NULL AND > 0 AND u.silenced_till IS NULL AND
#{SiteSetting.must_approve_users ? 'AND u.approved' : ''}
", period_type: period_types[period_type]

# Calculate new values and update records
@@ -143,5 +143,17 @@
expect(monthly_directory_item.days_visited).to eq(3)

context 'must approve users' do
before do
SiteSetting.must_approve_users = true

it "doesn't include user who hasn't been approved" do
user = Fabricate(:user, approved: false)
expect(DirectoryItem.where(user_id: eq(0)


1 comment on commit 7331e08


This comment has been minimized.

Copy link

commented on 7331e08 Sep 11, 2019

This commit has been mentioned on Discourse Meta. There might be relevant details there:

Please sign in to comment.
You can’t perform that action at this time.