Skip to content

Commit 3b15e2e

Browse files
committed
Banned users are not returned as pending review users
1 parent 25e0c3e commit 3b15e2e

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

app/models/user.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class User < ActiveRecord::Base
6868

6969
scope :blocked, -> { where(blocked: true) } # no index
7070
scope :banned, -> { where('banned_till IS NOT NULL AND banned_till > ?', Time.zone.now) } # no index
71+
scope :not_banned, -> { where('banned_till IS NULL') }
7172

7273
module NewTopicDuration
7374
ALWAYS = -1

lib/admin_user_index_query.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def filter_by_query_classification
3030
when 'moderators' then @query.where('moderator = ?', true)
3131
when 'blocked' then @query.blocked
3232
when 'banned' then @query.banned
33-
when 'pending' then @query.where('approved = false')
33+
when 'pending' then @query.not_banned.where('approved = false')
3434
end
3535
end
3636

spec/components/admin_user_index_query_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
expect(query.find_users.count).to eq(1)
4747
end
4848

49+
context 'and a banned pending user' do
50+
let!(:banned_user) { Fabricate(:user, approved: false, banned_at: 1.hour.ago, banned_till: 20.years.from_now) }
51+
it "doesn't return the banned user" do
52+
query = ::AdminUserIndexQuery.new({ query: 'pending' })
53+
expect(query.find_users.count).to eq(1)
54+
end
55+
end
56+
4957
end
5058

5159
describe "with an admin user" do

0 commit comments

Comments
 (0)