diff --git a/spec/controllers/admin/account_actions_controller_spec.rb b/spec/controllers/admin/account_actions_controller_spec.rb index d513b3d4a0..fabe5cef4d 100644 --- a/spec/controllers/admin/account_actions_controller_spec.rb +++ b/spec/controllers/admin/account_actions_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/account_moderation_notes_controller_spec.rb b/spec/controllers/admin/account_moderation_notes_controller_spec.rb index 5ea546f418..74610868dc 100644 --- a/spec/controllers/admin/account_moderation_notes_controller_spec.rb +++ b/spec/controllers/admin/account_moderation_notes_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index a182300106..72ca2275cf 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -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) } diff --git a/spec/controllers/admin/action_logs_controller_spec.rb b/spec/controllers/admin/action_logs_controller_spec.rb index 3daf260672..d3108e8055 100644 --- a/spec/controllers/admin/action_logs_controller_spec.rb +++ b/spec/controllers/admin/action_logs_controller_spec.rb @@ -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) diff --git a/spec/controllers/admin/base_controller_spec.rb b/spec/controllers/admin/base_controller_spec.rb index 8b8b7fe63d..6e78ccb3b1 100644 --- a/spec/controllers/admin/base_controller_spec.rb +++ b/spec/controllers/admin/base_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/change_emails_controller_spec.rb b/spec/controllers/admin/change_emails_controller_spec.rb index dd8a764b64..899106e54e 100644 --- a/spec/controllers/admin/change_emails_controller_spec.rb +++ b/spec/controllers/admin/change_emails_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/confirmations_controller_spec.rb b/spec/controllers/admin/confirmations_controller_spec.rb index 59ea0121ca..22035d15e6 100644 --- a/spec/controllers/admin/confirmations_controller_spec.rb +++ b/spec/controllers/admin/confirmations_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/custom_emojis_controller_spec.rb b/spec/controllers/admin/custom_emojis_controller_spec.rb index 57c2a6d21b..1ba5c0ebcb 100644 --- a/spec/controllers/admin/custom_emojis_controller_spec.rb +++ b/spec/controllers/admin/custom_emojis_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/disputes/appeals_controller_spec.rb b/spec/controllers/admin/disputes/appeals_controller_spec.rb index 678ceee115..b67ee30f74 100644 --- a/spec/controllers/admin/disputes/appeals_controller_spec.rb +++ b/spec/controllers/admin/disputes/appeals_controller_spec.rb @@ -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 } diff --git a/spec/controllers/admin/domain_allows_controller_spec.rb b/spec/controllers/admin/domain_allows_controller_spec.rb index 036d229091..c29e53a1c3 100644 --- a/spec/controllers/admin/domain_allows_controller_spec.rb +++ b/spec/controllers/admin/domain_allows_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/domain_blocks_controller_spec.rb b/spec/controllers/admin/domain_blocks_controller_spec.rb index a99ca6c641..4d48a0d9d3 100644 --- a/spec/controllers/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/domain_blocks_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/email_domain_blocks_controller_spec.rb b/spec/controllers/admin/email_domain_blocks_controller_spec.rb index 4de3ef0f62..c7460c2110 100644 --- a/spec/controllers/admin/email_domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/email_domain_blocks_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/export_domain_allows_controller_spec.rb b/spec/controllers/admin/export_domain_allows_controller_spec.rb index 0a2e342620..2aa21be09d 100644 --- a/spec/controllers/admin/export_domain_allows_controller_spec.rb +++ b/spec/controllers/admin/export_domain_allows_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/export_domain_blocks_controller_spec.rb b/spec/controllers/admin/export_domain_blocks_controller_spec.rb index 564f5a88c5..442f3e5a15 100644 --- a/spec/controllers/admin/export_domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/export_domain_blocks_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/follow_recommendations_controller_spec.rb b/spec/controllers/admin/follow_recommendations_controller_spec.rb index d614f2ef43..82446cd467 100644 --- a/spec/controllers/admin/follow_recommendations_controller_spec.rb +++ b/spec/controllers/admin/follow_recommendations_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/instances_controller_spec.rb b/spec/controllers/admin/instances_controller_spec.rb index 1e65373e1f..83655bafa0 100644 --- a/spec/controllers/admin/instances_controller_spec.rb +++ b/spec/controllers/admin/instances_controller_spec.rb @@ -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') } diff --git a/spec/controllers/admin/ip_blocks_controller_spec.rb b/spec/controllers/admin/ip_blocks_controller_spec.rb index 2e32db5a01..71aa3bf059 100644 --- a/spec/controllers/admin/ip_blocks_controller_spec.rb +++ b/spec/controllers/admin/ip_blocks_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/relationships_controller_spec.rb b/spec/controllers/admin/relationships_controller_spec.rb index 214be7c7cd..1d300459f6 100644 --- a/spec/controllers/admin/relationships_controller_spec.rb +++ b/spec/controllers/admin/relationships_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/relays_controller_spec.rb b/spec/controllers/admin/relays_controller_spec.rb index c6251a6d76..1409c3cbe3 100644 --- a/spec/controllers/admin/relays_controller_spec.rb +++ b/spec/controllers/admin/relays_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/report_notes_controller_spec.rb b/spec/controllers/admin/report_notes_controller_spec.rb index 423a64ebc4..ac2bf9b730 100644 --- a/spec/controllers/admin/report_notes_controller_spec.rb +++ b/spec/controllers/admin/report_notes_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/reports/actions_controller_spec.rb b/spec/controllers/admin/reports/actions_controller_spec.rb index 6185702c30..87a48a7a3a 100644 --- a/spec/controllers/admin/reports/actions_controller_spec.rb +++ b/spec/controllers/admin/reports/actions_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index 1252ceb1f4..4012204de1 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/rules_controller_spec.rb b/spec/controllers/admin/rules_controller_spec.rb index 1b2a2010d0..531791f32b 100644 --- a/spec/controllers/admin/rules_controller_spec.rb +++ b/spec/controllers/admin/rules_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/settings/branding_controller_spec.rb b/spec/controllers/admin/settings/branding_controller_spec.rb index 5e46910cc6..843021469e 100644 --- a/spec/controllers/admin/settings/branding_controller_spec.rb +++ b/spec/controllers/admin/settings/branding_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/site_uploads_controller_spec.rb b/spec/controllers/admin/site_uploads_controller_spec.rb index 9c65c63b78..1fe5903498 100644 --- a/spec/controllers/admin/site_uploads_controller_spec.rb +++ b/spec/controllers/admin/site_uploads_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/statuses_controller_spec.rb b/spec/controllers/admin/statuses_controller_spec.rb index e6053a6e8a..2809c8ec3f 100644 --- a/spec/controllers/admin/statuses_controller_spec.rb +++ b/spec/controllers/admin/statuses_controller_spec.rb @@ -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) } diff --git a/spec/controllers/admin/trends/links/preview_card_providers_controller_spec.rb b/spec/controllers/admin/trends/links/preview_card_providers_controller_spec.rb index ce62a13db6..aadf002dd6 100644 --- a/spec/controllers/admin/trends/links/preview_card_providers_controller_spec.rb +++ b/spec/controllers/admin/trends/links/preview_card_providers_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/trends/links_controller_spec.rb b/spec/controllers/admin/trends/links_controller_spec.rb index 984f3007c2..cd2cf6b852 100644 --- a/spec/controllers/admin/trends/links_controller_spec.rb +++ b/spec/controllers/admin/trends/links_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/trends/statuses_controller_spec.rb b/spec/controllers/admin/trends/statuses_controller_spec.rb index eecf4ab4f2..6570340b2d 100644 --- a/spec/controllers/admin/trends/statuses_controller_spec.rb +++ b/spec/controllers/admin/trends/statuses_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/trends/tags_controller_spec.rb b/spec/controllers/admin/trends/tags_controller_spec.rb index 51ad1860c8..83ea23ed21 100644 --- a/spec/controllers/admin/trends/tags_controller_spec.rb +++ b/spec/controllers/admin/trends/tags_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb b/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb index 1f0a6ac34d..39af2ca914 100644 --- a/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb +++ b/spec/controllers/admin/users/two_factor_authentications_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/warning_presets_controller_spec.rb b/spec/controllers/admin/warning_presets_controller_spec.rb index 4171bbad82..d416b9c3cf 100644 --- a/spec/controllers/admin/warning_presets_controller_spec.rb +++ b/spec/controllers/admin/warning_presets_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/webhooks/secrets_controller_spec.rb b/spec/controllers/admin/webhooks/secrets_controller_spec.rb index 61ae8cdaa5..da3d4f1438 100644 --- a/spec/controllers/admin/webhooks/secrets_controller_spec.rb +++ b/spec/controllers/admin/webhooks/secrets_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/webhooks_controller_spec.rb b/spec/controllers/admin/webhooks_controller_spec.rb index 4fe787c26c..7c78ba5400 100644 --- a/spec/controllers/admin/webhooks_controller_spec.rb +++ b/spec/controllers/admin/webhooks_controller_spec.rb @@ -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 diff --git a/spec/controllers/disputes/appeals_controller_spec.rb b/spec/controllers/disputes/appeals_controller_spec.rb index 3e874bbdcc..610e7c9cc2 100644 --- a/spec/controllers/disputes/appeals_controller_spec.rb +++ b/spec/controllers/disputes/appeals_controller_spec.rb @@ -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 } diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb index 0df7caea60..83547adcfd 100644 --- a/spec/fabricators/user_fabricator.rb +++ b/spec/fabricators/user_fabricator.rb @@ -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 diff --git a/spec/models/admin/account_action_spec.rb b/spec/models/admin/account_action_spec.rb index 49bc2b4a91..6032594850 100644 --- a/spec/models/admin/account_action_spec.rb +++ b/spec/models/admin/account_action_spec.rb @@ -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' } diff --git a/spec/models/form/account_batch_spec.rb b/spec/models/form/account_batch_spec.rb index 26fb1b953a..8db9a2a254 100644 --- a/spec/models/form/account_batch_spec.rb +++ b/spec/models/form/account_batch_spec.rb @@ -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 } diff --git a/spec/models/form/custom_emoji_batch_spec.rb b/spec/models/form/custom_emoji_batch_spec.rb index 180c6abd23..ca9740de3e 100644 --- a/spec/models/form/custom_emoji_batch_spec.rb +++ b/spec/models/form/custom_emoji_batch_spec.rb @@ -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: [] } } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9a5a070d25..6862979787 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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]) diff --git a/spec/policies/account_moderation_note_policy_spec.rb b/spec/policies/account_moderation_note_policy_spec.rb index 8b33a71012..2a9cdabaa2 100644 --- a/spec/policies/account_moderation_note_policy_spec.rb +++ b/spec/policies/account_moderation_note_policy_spec.rb @@ -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 diff --git a/spec/policies/account_policy_spec.rb b/spec/policies/account_policy_spec.rb index 75724e831b..8b2edb15b0 100644 --- a/spec/policies/account_policy_spec.rb +++ b/spec/policies/account_policy_spec.rb @@ -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 diff --git a/spec/policies/account_warning_policy_spec.rb b/spec/policies/account_warning_policy_spec.rb index 9abc9d35d6..75142e2071 100644 --- a/spec/policies/account_warning_policy_spec.rb +++ b/spec/policies/account_warning_policy_spec.rb @@ -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 diff --git a/spec/policies/account_warning_preset_policy_spec.rb b/spec/policies/account_warning_preset_policy_spec.rb index 33f2fb1187..e8223ab1c7 100644 --- a/spec/policies/account_warning_preset_policy_spec.rb +++ b/spec/policies/account_warning_preset_policy_spec.rb @@ -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 diff --git a/spec/policies/admin/status_policy_spec.rb b/spec/policies/admin/status_policy_spec.rb index 4df29393e3..5f8285c562 100644 --- a/spec/policies/admin/status_policy_spec.rb +++ b/spec/policies/admin/status_policy_spec.rb @@ -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 } diff --git a/spec/policies/announcement_policy_spec.rb b/spec/policies/announcement_policy_spec.rb index ab0c1dbaf5..2fec34f8e4 100644 --- a/spec/policies/announcement_policy_spec.rb +++ b/spec/policies/announcement_policy_spec.rb @@ -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 diff --git a/spec/policies/appeal_policy_spec.rb b/spec/policies/appeal_policy_spec.rb index cdb93bf56c..e3e1d62ba7 100644 --- a/spec/policies/appeal_policy_spec.rb +++ b/spec/policies/appeal_policy_spec.rb @@ -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) } diff --git a/spec/policies/audit_log_policy_spec.rb b/spec/policies/audit_log_policy_spec.rb index d9d9359433..b1769eb487 100644 --- a/spec/policies/audit_log_policy_spec.rb +++ b/spec/policies/audit_log_policy_spec.rb @@ -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 diff --git a/spec/policies/canonical_email_block_policy_spec.rb b/spec/policies/canonical_email_block_policy_spec.rb index b253b439a6..bf9503dc5c 100644 --- a/spec/policies/canonical_email_block_policy_spec.rb +++ b/spec/policies/canonical_email_block_policy_spec.rb @@ -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 diff --git a/spec/policies/custom_emoji_policy_spec.rb b/spec/policies/custom_emoji_policy_spec.rb index 189885938c..9635da4496 100644 --- a/spec/policies/custom_emoji_policy_spec.rb +++ b/spec/policies/custom_emoji_policy_spec.rb @@ -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 diff --git a/spec/policies/dashboard_policy_spec.rb b/spec/policies/dashboard_policy_spec.rb index 90c71db381..711bea53ec 100644 --- a/spec/policies/dashboard_policy_spec.rb +++ b/spec/policies/dashboard_policy_spec.rb @@ -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 diff --git a/spec/policies/delivery_policy_spec.rb b/spec/policies/delivery_policy_spec.rb index 8bc200159a..017a7f3c5e 100644 --- a/spec/policies/delivery_policy_spec.rb +++ b/spec/policies/delivery_policy_spec.rb @@ -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 diff --git a/spec/policies/domain_allow_policy_spec.rb b/spec/policies/domain_allow_policy_spec.rb index 1d285065b8..1e29c4144f 100644 --- a/spec/policies/domain_allow_policy_spec.rb +++ b/spec/policies/domain_allow_policy_spec.rb @@ -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 diff --git a/spec/policies/domain_block_policy_spec.rb b/spec/policies/domain_block_policy_spec.rb index 7c77d1870d..04081c5c9b 100644 --- a/spec/policies/domain_block_policy_spec.rb +++ b/spec/policies/domain_block_policy_spec.rb @@ -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 diff --git a/spec/policies/email_domain_block_policy_spec.rb b/spec/policies/email_domain_block_policy_spec.rb index e98d65a3c7..6428a2b442 100644 --- a/spec/policies/email_domain_block_policy_spec.rb +++ b/spec/policies/email_domain_block_policy_spec.rb @@ -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 diff --git a/spec/policies/follow_recommendation_policy_spec.rb b/spec/policies/follow_recommendation_policy_spec.rb index 665ed9b059..181f0ed11c 100644 --- a/spec/policies/follow_recommendation_policy_spec.rb +++ b/spec/policies/follow_recommendation_policy_spec.rb @@ -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 diff --git a/spec/policies/instance_policy_spec.rb b/spec/policies/instance_policy_spec.rb index 6cdc738022..7ab843b83b 100644 --- a/spec/policies/instance_policy_spec.rb +++ b/spec/policies/instance_policy_spec.rb @@ -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 diff --git a/spec/policies/invite_policy_spec.rb b/spec/policies/invite_policy_spec.rb index 3717a44999..bb3bddd4b8 100644 --- a/spec/policies/invite_policy_spec.rb +++ b/spec/policies/invite_policy_spec.rb @@ -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 diff --git a/spec/policies/ip_block_policy_spec.rb b/spec/policies/ip_block_policy_spec.rb index 33ea342c10..dcd9c19785 100644 --- a/spec/policies/ip_block_policy_spec.rb +++ b/spec/policies/ip_block_policy_spec.rb @@ -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 diff --git a/spec/policies/preview_card_policy_spec.rb b/spec/policies/preview_card_policy_spec.rb index d02a6016cd..75fcf7b373 100644 --- a/spec/policies/preview_card_policy_spec.rb +++ b/spec/policies/preview_card_policy_spec.rb @@ -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 diff --git a/spec/policies/preview_card_provider_policy_spec.rb b/spec/policies/preview_card_provider_policy_spec.rb index 5e25b364a4..d3fbf44539 100644 --- a/spec/policies/preview_card_provider_policy_spec.rb +++ b/spec/policies/preview_card_provider_policy_spec.rb @@ -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 diff --git a/spec/policies/relay_policy_spec.rb b/spec/policies/relay_policy_spec.rb index 5983b2d2ff..8d5ed4997e 100644 --- a/spec/policies/relay_policy_spec.rb +++ b/spec/policies/relay_policy_spec.rb @@ -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 diff --git a/spec/policies/report_note_policy_spec.rb b/spec/policies/report_note_policy_spec.rb index 02317f763a..9f0c525a3c 100644 --- a/spec/policies/report_note_policy_spec.rb +++ b/spec/policies/report_note_policy_spec.rb @@ -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 diff --git a/spec/policies/report_policy_spec.rb b/spec/policies/report_policy_spec.rb index 67f40b5188..20b91c5fd0 100644 --- a/spec/policies/report_policy_spec.rb +++ b/spec/policies/report_policy_spec.rb @@ -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 diff --git a/spec/policies/rule_policy_spec.rb b/spec/policies/rule_policy_spec.rb index 3086f30446..70ae3f9417 100644 --- a/spec/policies/rule_policy_spec.rb +++ b/spec/policies/rule_policy_spec.rb @@ -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 diff --git a/spec/policies/settings_policy_spec.rb b/spec/policies/settings_policy_spec.rb index 48821c706a..d11c3c1fa7 100644 --- a/spec/policies/settings_policy_spec.rb +++ b/spec/policies/settings_policy_spec.rb @@ -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 diff --git a/spec/policies/status_policy_spec.rb b/spec/policies/status_policy_spec.rb index 538742610c..69c0bad026 100644 --- a/spec/policies/status_policy_spec.rb +++ b/spec/policies/status_policy_spec.rb @@ -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) } diff --git a/spec/policies/tag_policy_spec.rb b/spec/policies/tag_policy_spec.rb index 23166e4669..241f13dd3b 100644 --- a/spec/policies/tag_policy_spec.rb +++ b/spec/policies/tag_policy_spec.rb @@ -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 diff --git a/spec/policies/user_policy_spec.rb b/spec/policies/user_policy_spec.rb index 11a166a24e..ba4e31189a 100644 --- a/spec/policies/user_policy_spec.rb +++ b/spec/policies/user_policy_spec.rb @@ -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 diff --git a/spec/policies/user_role_policy_spec.rb b/spec/policies/user_role_policy_spec.rb index c48b345d68..7708dfea55 100644 --- a/spec/policies/user_role_policy_spec.rb +++ b/spec/policies/user_role_policy_spec.rb @@ -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 diff --git a/spec/policies/webhook_policy_spec.rb b/spec/policies/webhook_policy_spec.rb index 9899235d83..10b5968165 100644 --- a/spec/policies/webhook_policy_spec.rb +++ b/spec/policies/webhook_policy_spec.rb @@ -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 diff --git a/spec/requests/api/v1/admin/dimensions_spec.rb b/spec/requests/api/v1/admin/dimensions_spec.rb index 81fb580ba7..3a4cd91716 100644 --- a/spec/requests/api/v1/admin/dimensions_spec.rb +++ b/spec/requests/api/v1/admin/dimensions_spec.rb @@ -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) } diff --git a/spec/requests/api/v1/admin/measures_spec.rb b/spec/requests/api/v1/admin/measures_spec.rb index 519b5cc7b3..b55cd0f1b2 100644 --- a/spec/requests/api/v1/admin/measures_spec.rb +++ b/spec/requests/api/v1/admin/measures_spec.rb @@ -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) } diff --git a/spec/requests/api/v1/admin/retention_spec.rb b/spec/requests/api/v1/admin/retention_spec.rb index e28bc2a94f..25e626e259 100644 --- a/spec/requests/api/v1/admin/retention_spec.rb +++ b/spec/requests/api/v1/admin/retention_spec.rb @@ -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) } diff --git a/spec/requests/api/v1/reports_spec.rb b/spec/requests/api/v1/reports_spec.rb index 18b894bf63..1f113c649e 100644 --- a/spec/requests/api/v1/reports_spec.rb +++ b/spec/requests/api/v1/reports_spec.rb @@ -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' } diff --git a/spec/requests/cache_spec.rb b/spec/requests/cache_spec.rb index 9cce241b38..2a52e4dea9 100644 --- a/spec/requests/cache_spec.rb +++ b/spec/requests/cache_spec.rb @@ -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') diff --git a/spec/services/appeal_service_spec.rb b/spec/services/appeal_service_spec.rb index 6a47bb2cea..a4b1acf9cf 100644 --- a/spec/services/appeal_service_spec.rb +++ b/spec/services/appeal_service_spec.rb @@ -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) } diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb index 4cc1928701..18889844f8 100644 --- a/spec/support/system_helpers.rb +++ b/spec/support/system_helpers.rb @@ -2,7 +2,7 @@ module SystemHelpers def admin_user - Fabricate(:user, role: UserRole.find_by(name: 'Admin')) + Fabricate(:admin_user) end def submit_button diff --git a/spec/system/admin/accounts_spec.rb b/spec/system/admin/accounts_spec.rb index c21e01e4f3..30504ce5d7 100644 --- a/spec/system/admin/accounts_spec.rb +++ b/spec/system/admin/accounts_spec.rb @@ -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 diff --git a/spec/system/admin/announcements_spec.rb b/spec/system/admin/announcements_spec.rb index 87b7332639..65768eb18b 100644 --- a/spec/system/admin/announcements_spec.rb +++ b/spec/system/admin/announcements_spec.rb @@ -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 diff --git a/spec/system/admin/custom_emojis_spec.rb b/spec/system/admin/custom_emojis_spec.rb index e47f21f8a9..cce8440a83 100644 --- a/spec/system/admin/custom_emojis_spec.rb +++ b/spec/system/admin/custom_emojis_spec.rb @@ -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 diff --git a/spec/system/admin/domain_blocks_spec.rb b/spec/system/admin/domain_blocks_spec.rb index f00d65dfe0..56a5d11984 100644 --- a/spec/system/admin/domain_blocks_spec.rb +++ b/spec/system/admin/domain_blocks_spec.rb @@ -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 diff --git a/spec/system/admin/email_domain_blocks_spec.rb b/spec/system/admin/email_domain_blocks_spec.rb index a90bede827..acf5027eda 100644 --- a/spec/system/admin/email_domain_blocks_spec.rb +++ b/spec/system/admin/email_domain_blocks_spec.rb @@ -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 diff --git a/spec/system/admin/invites_spec.rb b/spec/system/admin/invites_spec.rb index f2cee626c6..cc1e4bae18 100644 --- a/spec/system/admin/invites_spec.rb +++ b/spec/system/admin/invites_spec.rb @@ -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 } diff --git a/spec/system/admin/ip_blocks_spec.rb b/spec/system/admin/ip_blocks_spec.rb index 9c03520277..27e89fa4d0 100644 --- a/spec/system/admin/ip_blocks_spec.rb +++ b/spec/system/admin/ip_blocks_spec.rb @@ -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 diff --git a/spec/system/admin/reset_spec.rb b/spec/system/admin/reset_spec.rb index d0f70a93f0..5cd0c048bb 100644 --- a/spec/system/admin/reset_spec.rb +++ b/spec/system/admin/reset_spec.rb @@ -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 diff --git a/spec/system/admin/statuses_spec.rb b/spec/system/admin/statuses_spec.rb index bb76a2963d..998ffc89df 100644 --- a/spec/system/admin/statuses_spec.rb +++ b/spec/system/admin/statuses_spec.rb @@ -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 diff --git a/spec/system/admin/tags_spec.rb b/spec/system/admin/tags_spec.rb index a3eca80d13..91227f0ca7 100644 --- a/spec/system/admin/tags_spec.rb +++ b/spec/system/admin/tags_spec.rb @@ -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 diff --git a/spec/system/admin/trends/links/preview_card_providers_spec.rb b/spec/system/admin/trends/links/preview_card_providers_spec.rb index 16343a6891..0a5b5a7581 100644 --- a/spec/system/admin/trends/links/preview_card_providers_spec.rb +++ b/spec/system/admin/trends/links/preview_card_providers_spec.rb @@ -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 diff --git a/spec/system/admin/trends/links_spec.rb b/spec/system/admin/trends/links_spec.rb index 7a51c337c9..15138f42d1 100644 --- a/spec/system/admin/trends/links_spec.rb +++ b/spec/system/admin/trends/links_spec.rb @@ -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 diff --git a/spec/system/admin/trends/statuses_spec.rb b/spec/system/admin/trends/statuses_spec.rb index 13fc966dfd..45c048afb0 100644 --- a/spec/system/admin/trends/statuses_spec.rb +++ b/spec/system/admin/trends/statuses_spec.rb @@ -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 diff --git a/spec/system/admin/trends/tags_spec.rb b/spec/system/admin/trends/tags_spec.rb index d914badbd4..30b0850b93 100644 --- a/spec/system/admin/trends/tags_spec.rb +++ b/spec/system/admin/trends/tags_spec.rb @@ -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 diff --git a/spec/workers/scheduler/auto_close_registrations_scheduler_spec.rb b/spec/workers/scheduler/auto_close_registrations_scheduler_spec.rb index d9355248ba..29b2b5b84c 100644 --- a/spec/workers/scheduler/auto_close_registrations_scheduler_spec.rb +++ b/spec/workers/scheduler/auto_close_registrations_scheduler_spec.rb @@ -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