Add role-specific user fabricators (#33437)

This commit is contained in:
Matt Jankowski 2025-01-03 03:28:14 -05:00 committed by GitHub
parent a8a16695f1
commit 7cbdcd7b3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
105 changed files with 125 additions and 113 deletions

View file

@ -601,7 +601,7 @@ RSpec.describe User do
end
describe '.those_who_can' do
before { Fabricate(:user, role: UserRole.find_by(name: 'Moderator')) }
before { Fabricate(:moderator_user) }
context 'when there are not any user roles' do
before { UserRole.destroy_all }
@ -618,7 +618,7 @@ RSpec.describe User do
end
context 'when there are users with roles' do
let!(:admin_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let!(:admin_user) { Fabricate(:admin_user) }
it 'returns the users with the role' do
expect(described_class.those_who_can(:manage_blocks)).to eq([admin_user])