mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 00:45:10 +08:00
[FEATURE] Disallow ignoring self, admins or moderators users (#7202)
This commit is contained in:

committed by
Régis Hanol

parent
fed2dd9148
commit
3b59ff0d02
@ -2640,6 +2640,32 @@ describe Guardian do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#can_ignore_user?' do
|
||||
let(:guardian) { Guardian.new(user) }
|
||||
|
||||
context "when ignored user is the same as guardian user" do
|
||||
it 'does not allow ignoring user' do
|
||||
expect(guardian.can_ignore_user?(user.id)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "when ignored user is a staff user" do
|
||||
let!(:admin) { Fabricate(:user, admin: true) }
|
||||
|
||||
it 'does not allow ignoring user' do
|
||||
expect(guardian.can_ignore_user?(admin.id)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "when ignored user is a normal user" do
|
||||
let!(:another_user) { Fabricate(:user) }
|
||||
|
||||
it 'allows ignoring user' do
|
||||
expect(guardian.can_ignore_user?(another_user.id)).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#allow_themes?" do
|
||||
let(:theme) { Fabricate(:theme) }
|
||||
let(:theme2) { Fabricate(:theme) }
|
||||
|
Reference in New Issue
Block a user