From ed73cc60a99aebb30c0631e2e5862bf987367da2 Mon Sep 17 00:00:00 2001 From: Tarek Khalil <45508821+khalilovcmded@users.noreply.github.com> Date: Wed, 20 Mar 2019 14:47:13 +0000 Subject: [PATCH] FIX: Staff should be allowed to ignore users (#7216) --- lib/guardian.rb | 2 +- spec/components/guardian_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/guardian.rb b/lib/guardian.rb index 3bab77eefbf..7bcc15971c7 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -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 diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index e0417a79593..eb4008efc1f 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -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) }