[FEATURE] Disallow ignoring self, admins or moderators users (#7202)

This commit is contained in:
Tarek Khalil
2019-03-20 10:18:46 +00:00
committed by Régis Hanol
parent fed2dd9148
commit 3b59ff0d02
10 changed files with 90 additions and 21 deletions

View File

@ -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) }