FIX: Staff should be allowed to ignore users (#7216)

This commit is contained in:
Tarek Khalil 2019-03-20 14:47:13 +00:00 committed by Régis Hanol
parent 5852e86226
commit ed73cc60a9
2 changed files with 10 additions and 1 deletions

View File

@ -392,7 +392,7 @@ class Guardian
def can_ignore_user?(user_id)
@user.id != user_id &&
@user.trust_level >= TrustLevel.levels[:member] &&
(@user.staff? || @user.trust_level >= TrustLevel.levels[:member]) &&
User.where(id: user_id, admin: false, moderator: false).exists?
end

View File

@ -2675,6 +2675,15 @@ describe Guardian do
end
end
context "when ignorer is staff" do
let(:guardian) { Guardian.new(admin) }
let!(:another_user) { Fabricate(:user) }
it 'allows ignoring user' do
expect(guardian.can_ignore_user?(another_user.id)).to eq(true)
end
end
context "when ignorer's trust level is tl2" do
let(:guardian) { Guardian.new(trust_level_2) }
let!(:another_user) { Fabricate(:user) }