mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add site setting to restrict ignore feature to trust level (#11297)
This adds a new min_trust_level_to_allow_ignore site setting that enables admins to control the point at which a user is allowed to ignore other users.
This commit is contained in:
@@ -2960,6 +2960,9 @@ describe Guardian do
|
||||
end
|
||||
|
||||
describe '#can_ignore_user?' do
|
||||
before do
|
||||
SiteSetting.min_trust_level_to_allow_ignore = 1
|
||||
end
|
||||
|
||||
let(:guardian) { Guardian.new(trust_level_2) }
|
||||
|
||||
@@ -2983,26 +2986,29 @@ describe Guardian do
|
||||
end
|
||||
end
|
||||
|
||||
context "when ignorer's trust level is below tl2" do
|
||||
let(:guardian) { Guardian.new(trust_level_1) }
|
||||
let!(:trust_level_1) { build(:user, trust_level: 1) }
|
||||
|
||||
it 'does not allow ignoring user' do
|
||||
expect(guardian.can_ignore_user?(another_user)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "when ignorer is staff" do
|
||||
let(:guardian) { Guardian.new(admin) }
|
||||
|
||||
it 'allows ignoring user' do
|
||||
expect(guardian.can_ignore_user?(another_user)).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "when ignorer's trust level is tl2" do
|
||||
let(:guardian) { Guardian.new(trust_level_2) }
|
||||
context "when ignorer's trust level is below min_trust_level_to_allow_ignore" do
|
||||
let(:guardian) { Guardian.new(trust_level_0) }
|
||||
it 'does not allow ignoring user' do
|
||||
expect(guardian.can_ignore_user?(another_user)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "when ignorer's trust level is equal to min_trust_level_to_allow_ignore site setting" do
|
||||
let(:guardian) { Guardian.new(trust_level_1) }
|
||||
it 'allows ignoring user' do
|
||||
expect(guardian.can_ignore_user?(another_user)).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
context "when ignorer's trust level is above min_trust_level_to_allow_ignore site setting" do
|
||||
let(:guardian) { Guardian.new(trust_level_3) }
|
||||
it 'allows ignoring user' do
|
||||
expect(guardian.can_ignore_user?(another_user)).to eq(true)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user