FEATURE: Search filter for searching all PMs on a site for admin. (#11280)

Admins can search all PMS on a site by using the `in:all-pms` advanced filter.
This commit is contained in:
Roman Rizzi
2020-11-19 13:56:19 -03:00
committed by GitHub
parent 5202380a04
commit d815b95935
2 changed files with 34 additions and 2 deletions

View File

@@ -334,6 +334,26 @@ describe Search do
end
end
context 'all-pms flag' do
it 'returns matching PMs if the user is an admin' do
results = Search.execute('mars in:all-pms', guardian: Guardian.new(admin))
expect(results.posts).to include(reply, post2)
end
it 'returns nothing if the user is not an admin' do
results = Search.execute('mars in:all-pms', guardian: Guardian.new(Fabricate(:user)))
expect(results.posts).to be_empty
end
it 'returns nothing if the user is a moderator' do
results = Search.execute('mars in:all-pms', guardian: Guardian.new(Fabricate(:moderator)))
expect(results.posts).to be_empty
end
end
context 'personal-direct flag' do
let(:current) { Fabricate(:user, admin: true, username: "current_user") }
let(:participant) { Fabricate(:user, username: "participant_1") }