Add fabricators for admin-role and moderator-role users

pull/32893/head
Matt Jankowski 2024-11-14 12:14:09 -05:00
parent 295ad6f19a
commit 9c381faec1
93 changed files with 108 additions and 100 deletions

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::AccountActionsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::AccountModerationNotesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
let(:target_account) { Fabricate(:account) }
before do

View File

@ -8,7 +8,7 @@ RSpec.describe Admin::AccountsController do
before { sign_in current_user, scope: :user }
describe 'GET #index' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
let(:params) do
{
origin: 'local',
@ -53,7 +53,7 @@ RSpec.describe Admin::AccountsController do
end
describe 'GET #show' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
describe 'account moderation notes' do
let(:account) { Fabricate(:account) }

View File

@ -16,7 +16,7 @@ RSpec.describe Admin::ActionLogsController do
describe 'GET #index' do
it 'returns 200' do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
sign_in Fabricate(:admin_user)
get :index, params: { page: 1 }
expect(response).to have_http_status(200)

View File

@ -20,7 +20,7 @@ RSpec.describe Admin::BaseController do
it 'returns private cache control headers' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
sign_in(Fabricate(:moderator_user))
get :success
expect(response.headers['Cache-Control']).to include('private, no-store')
@ -28,14 +28,14 @@ RSpec.describe Admin::BaseController do
it 'renders admin layout as a moderator' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
sign_in(Fabricate(:moderator_user))
get :success
expect(response).to render_template layout: 'admin'
end
it 'renders admin layout as an admin' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Admin')))
sign_in(Fabricate(:admin_user))
get :success
expect(response).to render_template layout: 'admin'
end

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::ChangeEmailsController do
render_views
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:admin) { Fabricate(:admin_user) }
before do
sign_in admin

View File

@ -6,7 +6,7 @@ RSpec.describe Admin::ConfirmationsController do
render_views
before do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
describe 'POST #create' do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::CustomEmojisController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -16,7 +16,7 @@ RSpec.describe Admin::Disputes::AppealsController do
let(:appeal) { Fabricate(:appeal, strike: strike, account: target_account) }
describe 'GET #index' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before { appeal }
@ -32,7 +32,7 @@ RSpec.describe Admin::Disputes::AppealsController do
describe 'POST #approve' do
subject { post :approve, params: { id: appeal.id } }
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
it 'redirects back to the strike page and notifies target account about approved appeal', :inline_jobs do
emails = capture_emails { subject }
@ -56,7 +56,7 @@ RSpec.describe Admin::Disputes::AppealsController do
describe 'POST #reject' do
subject { post :reject, params: { id: appeal.id } }
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
it 'redirects back to the strike page and notifies target account about rejected appeal', :inline_jobs do
emails = capture_emails { subject }

View File

@ -6,7 +6,7 @@ RSpec.describe Admin::DomainAllowsController do
render_views
before do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
describe 'GET #new' do

View File

@ -6,7 +6,7 @@ RSpec.describe Admin::DomainBlocksController do
render_views
before do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
describe 'GET #new' do

View File

@ -6,7 +6,7 @@ RSpec.describe Admin::EmailDomainBlocksController do
render_views
before do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
describe 'GET #index' do

View File

@ -6,7 +6,7 @@ RSpec.describe Admin::ExportDomainAllowsController do
render_views
before do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
describe 'GET #new' do

View File

@ -6,7 +6,7 @@ RSpec.describe Admin::ExportDomainBlocksController do
render_views
before do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
describe 'GET #new' do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::FollowRecommendationsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::InstancesController do
render_views
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
let!(:account_popular_main) { Fabricate(:account, domain: 'popular') }

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::IpBlocksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::RelationshipsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::RelaysController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::ReportNotesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::Reports::ActionsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::ReportsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::RulesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -7,7 +7,7 @@ RSpec.describe Admin::Settings::BrandingController do
describe 'When signed in as an admin' do
before do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
describe 'PUT #update' do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::SiteUploadsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::StatusesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
let(:account) { Fabricate(:account) }
let!(:status) { Fabricate(:status, account: account) }
let(:media_attached_status) { Fabricate(:status, account: account, sensitive: !sensitive) }

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::Trends::Links::PreviewCardProvidersController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::Trends::LinksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::Trends::StatusesController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::Trends::TagsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -9,7 +9,7 @@ RSpec.describe Admin::Users::TwoFactorAuthenticationsController do
let(:user) { Fabricate(:user) }
before do
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
describe 'DELETE #destroy' do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::WarningPresetsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::Webhooks::SecretsController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe Admin::WebhooksController do
render_views
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before do
sign_in user, scope: :user

View File

@ -7,7 +7,7 @@ RSpec.describe Disputes::AppealsController do
before { sign_in current_user, scope: :user }
let!(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let!(:admin) { Fabricate(:admin_user) }
describe '#create' do
subject { post :create, params: params }

View File

@ -13,3 +13,11 @@ Fabricator(:user) do
current_sign_in_at { Time.zone.now }
agreement true
end
Fabricator(:admin_user, from: :user) do
role UserRole.find_by(name: 'Admin')
end
Fabricator(:moderator_user, from: :user) do
role UserRole.find_by(name: 'Moderator')
end

View File

@ -8,7 +8,7 @@ RSpec.describe Admin::AccountAction do
describe '#save!' do
subject { account_action.save! }
let(:account) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:account) { Fabricate(:admin_user).account }
let(:target_account) { Fabricate(:account) }
let(:type) { 'disable' }

View File

@ -8,7 +8,7 @@ RSpec.describe Form::AccountBatch do
describe '#save' do
subject { account_batch.save }
let(:account) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:account) { Fabricate(:admin_user).account }
let(:account_ids) { [] }
let(:query) { Account.none }

View File

@ -7,7 +7,7 @@ RSpec.describe Form::CustomEmojiBatch do
subject { described_class.new({ current_account: account }.merge(options)) }
let(:options) { {} }
let(:account) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:account) { Fabricate(:admin_user).account }
context 'with empty custom_emoji_ids' do
let(:options) { { custom_emoji_ids: [] } }

View File

@ -574,7 +574,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 }
@ -591,7 +591,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])

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe AccountModerationNotePolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :create? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe AccountPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
let(:alice) { Fabricate(:account) }
@ -70,7 +70,7 @@ RSpec.describe AccountPolicy do
end
permissions :suspend?, :silence? do
let(:staff) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:staff) { Fabricate(:admin_user).account }
context 'when staff' do
context 'when record is staff' do
@ -94,7 +94,7 @@ RSpec.describe AccountPolicy do
end
permissions :memorialize? do
let(:other_admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:other_admin) { Fabricate(:admin_user).account }
context 'when admin' do
context 'when record is admin' do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe AccountWarningPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:account) { Fabricate(:account) }
permissions :show? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe AccountWarningPresetPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :create?, :update?, :destroy? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe Admin::StatusPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
let(:status) { Fabricate(:status, visibility: status_visibility) }
let(:status_visibility) { :public }

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe AnnouncementPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :create?, :update?, :destroy? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe AppealPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
let(:appeal) { Fabricate(:appeal) }

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe AuditLogPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:account) { Fabricate(:account) }
permissions :index? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe CanonicalEmailBlockPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :show?, :test?, :create?, :destroy? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe CustomEmojiPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :enable?, :disable? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe DashboardPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:account) { Fabricate(:account) }
permissions :index? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe DeliveryPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :clear_delivery_errors?, :restart_delivery?, :stop_delivery? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe DomainAllowPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :show?, :create?, :destroy? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe DomainBlockPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :show?, :create?, :destroy?, :update? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe EmailDomainBlockPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :show?, :create?, :destroy? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe FollowRecommendationPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :show?, :suppress?, :unsuppress? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe InstancePolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :show?, :destroy? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe InvitePolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:user).account }
permissions :index? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe IpBlockPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :show?, :create?, :update?, :destroy? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe PreviewCardPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :review? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe PreviewCardProviderPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :review? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe RelayPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :update? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe ReportNotePolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :create? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe ReportPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :update?, :index?, :show? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe RulePolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :create?, :update?, :destroy? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe SettingsPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :update?, :show?, :destroy? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe StatusPolicy, type: :model do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:admin) { Fabricate(:admin_user) }
let(:alice) { Fabricate(:account, username: 'alice') }
let(:bob) { Fabricate(:account, username: 'bob') }
let(:status) { Fabricate(:status, account: alice) }

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe TagPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :show?, :update?, :review? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe UserPolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :reset_password?, :change_email? do

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe UserRolePolicy do
subject { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:account) { Fabricate(:account) }
permissions :index?, :create? do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe WebhookPolicy do
let(:policy) { described_class }
let(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:admin) { Fabricate(:admin_user).account }
let(:john) { Fabricate(:account) }
permissions :index?, :create? do

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin Dimensions' do
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
let(:account) { Fabricate(:account) }

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin Measures' do
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
let(:account) { Fabricate(:account) }

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin Retention' do
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) }
let(:headers) { { 'Authorization' => "Bearer #{token.token}" } }
let(:account) { Fabricate(:account) }

View File

@ -13,7 +13,7 @@ RSpec.describe 'Reports' do
post '/api/v1/reports', headers: headers, params: params
end
let!(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let!(:admin) { Fabricate(:admin_user) }
let(:status) { Fabricate(:status) }
let(:target_account) { status.account }
let(:category) { 'other' }

View File

@ -172,7 +172,7 @@ RSpec.describe 'Caching behavior' do
before_all do
alice = Fabricate(:account, username: 'alice')
user = Fabricate(:user, email: 'user@host.example', role: UserRole.find_by(name: 'Moderator'))
user = Fabricate(:moderator_user, email: 'user@host.example')
status = Fabricate(:status, account: alice, id: 110_224_538_612_341_312)
Fabricate(:status, account: alice, id: 110_224_538_643_211_312, visibility: :private)
Fabricate(:invite, code: 'abcdef')

View File

@ -4,7 +4,7 @@ require 'rails_helper'
RSpec.describe AppealService, :inline_jobs do
describe '#call' do
let!(:admin) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let!(:admin) { Fabricate(:admin_user) }
context 'with an existing strike' do
let(:strike) { Fabricate(:account_warning) }

View File

@ -2,7 +2,7 @@
module SystemHelpers
def admin_user
Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
Fabricate(:admin_user)
end
def submit_button

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::Accounts' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -121,6 +121,6 @@ RSpec.describe 'Admin::Announcements' do
end
def admin_user
Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
Fabricate(:admin_user)
end
end

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::CustomEmojis' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -5,7 +5,7 @@ require 'rails_helper'
RSpec.describe 'blocking domains through the moderation interface' do
before do
allow(DomainBlockWorker).to receive(:perform_async).and_return(true)
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')), scope: :user
sign_in Fabricate(:admin_user), scope: :user
end
context 'when silencing a new domain' do

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::EmailDomainBlocks' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -6,7 +6,7 @@ RSpec.describe 'Admin Invites' do
describe 'Invite interaction' do
let!(:invite) { Fabricate(:invite, expires_at: nil) }
let(:user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:user) { Fabricate(:admin_user) }
before { sign_in user }

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::IpBlocks' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -28,7 +28,7 @@ RSpec.describe 'Admin::Reset' do
end
def admin_user
Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
Fabricate(:admin_user)
end
def submit_reset

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::Statuses' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -6,7 +6,7 @@ RSpec.describe 'Admin Tags' do
describe 'Tag interaction' do
let!(:tag) { Fabricate(:tag, name: 'test') }
before { sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
before { sign_in Fabricate(:admin_user) }
it 'allows tags listing and editing' do
visit admin_tags_path

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::Trends::Links::PreviewCardProviders' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::Trends::Links' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::Trends::Statuses' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Admin::Trends::Tags' do
let(:current_user) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')) }
let(:current_user) { Fabricate(:admin_user) }
before do
sign_in current_user

View File

@ -10,7 +10,7 @@ RSpec.describe Scheduler::AutoCloseRegistrationsScheduler do
before do
Fabricate(:user, role: UserRole.find_by(name: 'Owner'), current_sign_in_at: 10.years.ago)
Fabricate(:user, role: UserRole.find_by(name: 'Moderator'), current_sign_in_at: moderator_activity_date)
Fabricate(:moderator_user, current_sign_in_at: moderator_activity_date)
end
context 'when registrations are open' do