From 68b1071f8634de1c15877215df73a7c006aa6222 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 07:45:27 -0500 Subject: Autofix Rubocop RSpec/BeNil (#23653) --- spec/controllers/activitypub/collections_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/controllers/activitypub/collections_controller_spec.rb') diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index f78d9abbf..4e35938db 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -10,7 +10,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do shared_examples 'cacheable response' do it 'does not set cookies' do expect(response.cookies).to be_empty - expect(response.headers['Set-Cookies']).to be nil + expect(response.headers['Set-Cookies']).to be_nil end it 'does not set sessions' do -- cgit From 65ba0d92ef78f82a3cf5bf04f13b3d7393da015d Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 20:33:27 -0500 Subject: Enable Rubocop RSpec/NotToNot (#23723) --- .rubocop.yml | 3 + .rubocop_todo.yml | 123 --------------------- .../activitypub/collections_controller_spec.rb | 4 +- .../activitypub/inboxes_controller_spec.rb | 6 +- .../account_moderation_notes_controller_spec.rb | 2 +- spec/controllers/admin/accounts_controller_spec.rb | 12 +- .../admin/change_email_controller_spec.rb | 2 +- .../admin/confirmations_controller_spec.rb | 2 +- .../admin/domain_blocks_controller_spec.rb | 2 +- .../admin/report_notes_controller_spec.rb | 4 +- .../settings/profiles_controller_spec.rb | 2 +- .../well_known/nodeinfo_controller_spec.rb | 2 +- spec/lib/activitypub/activity/announce_spec.rb | 2 +- spec/lib/request_spec.rb | 2 +- spec/lib/status_filter_spec.rb | 4 +- spec/lib/text_formatter_spec.rb | 2 +- spec/models/account_spec.rb | 10 +- spec/models/concerns/account_interactions_spec.rb | 6 +- spec/models/concerns/remotable_spec.rb | 4 +- spec/models/public_feed_spec.rb | 28 ++--- spec/models/setting_spec.rb | 4 +- spec/models/tag_spec.rb | 6 +- spec/models/user_spec.rb | 4 +- spec/services/account_search_service_spec.rb | 2 +- .../activitypub/process_collection_service_spec.rb | 10 +- .../process_status_update_service_spec.rb | 4 +- spec/services/block_domain_service_spec.rb | 6 +- spec/services/clear_domain_media_service_spec.rb | 6 +- spec/services/import_service_spec.rb | 2 +- spec/services/post_status_service_spec.rb | 4 +- spec/services/search_service_spec.rb | 6 +- .../validators/blacklisted_email_validator_spec.rb | 2 +- .../disallowed_hashtags_validator_spec.rb | 4 +- spec/validators/email_mx_validator_spec.rb | 2 +- spec/validators/follow_limit_validator_spec.rb | 4 +- spec/validators/poll_validator_spec.rb | 4 +- spec/validators/status_length_validator_spec.rb | 4 +- .../unreserved_username_validator_spec.rb | 4 +- spec/validators/url_validator_spec.rb | 2 +- spec/workers/feed_insert_worker_spec.rb | 6 +- 40 files changed, 94 insertions(+), 214 deletions(-) (limited to 'spec/controllers/activitypub/collections_controller_spec.rb') diff --git a/.rubocop.yml b/.rubocop.yml index 3783ccf48..fc1969a64 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -94,6 +94,9 @@ Rails/Exit: - 'lib/mastodon/cli_helper.rb' - 'lib/cli.rb' +RSpec/NotToNot: + EnforcedStyle: to_not + Style/HashSyntax: EnforcedStyle: ruby19_no_mixed_keys diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 73ebdbfd8..9076891e2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1440,129 +1440,6 @@ RSpec/NoExpectationExample: - 'spec/controllers/auth/registrations_controller_spec.rb' - 'spec/services/precompute_feed_service_spec.rb' -# Offense count: 370 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: not_to, to_not -RSpec/NotToNot: - Exclude: - - 'spec/config/initializers/rack_attack_spec.rb' - - 'spec/controllers/accounts_controller_spec.rb' - - 'spec/controllers/admin/accounts_controller_spec.rb' - - 'spec/controllers/admin/email_domain_blocks_controller_spec.rb' - - 'spec/controllers/admin/roles_controller_spec.rb' - - 'spec/controllers/api/v1/accounts_controller_spec.rb' - - 'spec/controllers/api/v1/admin/account_actions_controller_spec.rb' - - 'spec/controllers/api/v1/admin/accounts_controller_spec.rb' - - 'spec/controllers/api/v1/admin/domain_allows_controller_spec.rb' - - 'spec/controllers/api/v1/admin/domain_blocks_controller_spec.rb' - - 'spec/controllers/api/v1/announcements/reactions_controller_spec.rb' - - 'spec/controllers/api/v1/announcements_controller_spec.rb' - - 'spec/controllers/api/v1/apps/credentials_controller_spec.rb' - - 'spec/controllers/api/v1/apps_controller_spec.rb' - - 'spec/controllers/api/v1/filters_controller_spec.rb' - - 'spec/controllers/api/v1/media_controller_spec.rb' - - 'spec/controllers/api/v1/notifications_controller_spec.rb' - - 'spec/controllers/api/v1/polls/votes_controller_spec.rb' - - 'spec/controllers/api/v1/reports_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/mutes_controller_spec.rb' - - 'spec/controllers/api/v2/filters/keywords_controller_spec.rb' - - 'spec/controllers/api/v2/filters/statuses_controller_spec.rb' - - 'spec/controllers/api/v2/filters_controller_spec.rb' - - 'spec/controllers/auth/challenges_controller_spec.rb' - - 'spec/controllers/auth/confirmations_controller_spec.rb' - - 'spec/controllers/auth/passwords_controller_spec.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/controllers/concerns/challengable_concern_spec.rb' - - 'spec/controllers/oauth/authorized_applications_controller_spec.rb' - - 'spec/controllers/oauth/tokens_controller_spec.rb' - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - - 'spec/controllers/statuses_controller_spec.rb' - - 'spec/helpers/application_helper_spec.rb' - - 'spec/lib/activitypub/activity/announce_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/lib/activitypub/activity/delete_spec.rb' - - 'spec/lib/activitypub/activity/flag_spec.rb' - - 'spec/lib/activitypub/dereferencer_spec.rb' - - 'spec/lib/activitypub/tag_manager_spec.rb' - - 'spec/lib/delivery_failure_tracker_spec.rb' - - 'spec/lib/feed_manager_spec.rb' - - 'spec/lib/html_aware_formatter_spec.rb' - - 'spec/lib/request_pool_spec.rb' - - 'spec/lib/status_reach_finder_spec.rb' - - 'spec/lib/vacuum/access_tokens_vacuum_spec.rb' - - 'spec/lib/vacuum/backups_vacuum_spec.rb' - - 'spec/lib/vacuum/media_attachments_vacuum_spec.rb' - - 'spec/lib/vacuum/preview_cards_vacuum_spec.rb' - - 'spec/lib/vacuum/statuses_vacuum_spec.rb' - - 'spec/lib/vacuum/system_keys_vacuum_spec.rb' - - 'spec/models/account/field_spec.rb' - - 'spec/models/account_conversation_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/models/account_statuses_filter_spec.rb' - - 'spec/models/concerns/remotable_spec.rb' - - 'spec/models/concerns/status_threading_concern_spec.rb' - - 'spec/models/follow_spec.rb' - - 'spec/models/media_attachment_spec.rb' - - 'spec/models/status_spec.rb' - - 'spec/models/tag_feed_spec.rb' - - 'spec/models/trends/statuses_spec.rb' - - 'spec/models/trends/tags_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/models/webhook_spec.rb' - - 'spec/policies/account_moderation_note_policy_spec.rb' - - 'spec/policies/account_policy_spec.rb' - - 'spec/policies/backup_policy_spec.rb' - - 'spec/policies/custom_emoji_policy_spec.rb' - - 'spec/policies/domain_block_policy_spec.rb' - - 'spec/policies/email_domain_block_policy_spec.rb' - - 'spec/policies/instance_policy_spec.rb' - - 'spec/policies/invite_policy_spec.rb' - - 'spec/policies/relay_policy_spec.rb' - - 'spec/policies/report_note_policy_spec.rb' - - 'spec/policies/report_policy_spec.rb' - - 'spec/policies/settings_policy_spec.rb' - - 'spec/policies/status_policy_spec.rb' - - 'spec/policies/tag_policy_spec.rb' - - 'spec/policies/user_policy_spec.rb' - - 'spec/presenters/familiar_followers_presenter_spec.rb' - - 'spec/serializers/activitypub/note_spec.rb' - - 'spec/services/account_statuses_cleanup_service_spec.rb' - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/app_sign_up_service_spec.rb' - - 'spec/services/batched_remove_status_service_spec.rb' - - 'spec/services/block_domain_service_spec.rb' - - 'spec/services/bootstrap_timeline_service_spec.rb' - - 'spec/services/fan_out_on_write_service_spec.rb' - - 'spec/services/favourite_service_spec.rb' - - 'spec/services/fetch_link_card_service_spec.rb' - - 'spec/services/fetch_oembed_service_spec.rb' - - 'spec/services/fetch_remote_status_service_spec.rb' - - 'spec/services/follow_service_spec.rb' - - 'spec/services/mute_service_spec.rb' - - 'spec/services/notify_service_spec.rb' - - 'spec/services/remove_status_service_spec.rb' - - 'spec/services/report_service_spec.rb' - - 'spec/services/resolve_account_service_spec.rb' - - 'spec/services/search_service_spec.rb' - - 'spec/services/suspend_account_service_spec.rb' - - 'spec/services/unallow_domain_service_spec.rb' - - 'spec/services/unsuspend_account_service_spec.rb' - - 'spec/services/update_status_service_spec.rb' - - 'spec/support/examples/models/concerns/account_avatar.rb' - - 'spec/support/examples/models/concerns/account_header.rb' - - 'spec/validators/email_mx_validator_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - - 'spec/validators/reaction_validator_spec.rb' - - 'spec/validators/status_length_validator_spec.rb' - - 'spec/validators/unique_username_validator_spec.rb' - - 'spec/workers/activitypub/fetch_replies_worker_spec.rb' - - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' - # Offense count: 3 RSpec/PendingWithoutReason: Exclude: diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index 4e35938db..bf81cdb93 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -60,7 +60,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do end it 'does not include contents of private pinned status' do - expect(response.body).not_to include(private_pinned.text) + expect(response.body).to_not include(private_pinned.text) end context 'when account is permanently suspended' do @@ -115,7 +115,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do end it 'does not include contents of private pinned status' do - expect(response.body).not_to include(private_pinned.text) + expect(response.body).to_not include(private_pinned.text) end end diff --git a/spec/controllers/activitypub/inboxes_controller_spec.rb b/spec/controllers/activitypub/inboxes_controller_spec.rb index 2f023197b..7f4d6b2d3 100644 --- a/spec/controllers/activitypub/inboxes_controller_spec.rb +++ b/spec/controllers/activitypub/inboxes_controller_spec.rb @@ -68,7 +68,7 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do let(:synchronization_collection) { 'https://example.com/followers2' } it 'does not start a synchronization job' do - expect(ActivityPub::FollowersSynchronizationWorker).not_to have_received(:perform_async) + expect(ActivityPub::FollowersSynchronizationWorker).to_not have_received(:perform_async) end end @@ -76,13 +76,13 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do let(:synchronization_url) { 'https://example.org/followers' } it 'does not start a synchronization job' do - expect(ActivityPub::FollowersSynchronizationWorker).not_to have_received(:perform_async) + expect(ActivityPub::FollowersSynchronizationWorker).to_not have_received(:perform_async) end end context 'with matching digest' do it 'does not start a synchronization job' do - expect(ActivityPub::FollowersSynchronizationWorker).not_to have_received(:perform_async) + expect(ActivityPub::FollowersSynchronizationWorker).to_not have_received(:perform_async) end end diff --git a/spec/controllers/admin/account_moderation_notes_controller_spec.rb b/spec/controllers/admin/account_moderation_notes_controller_spec.rb index d3f3263f8..b8d606322 100644 --- a/spec/controllers/admin/account_moderation_notes_controller_spec.rb +++ b/spec/controllers/admin/account_moderation_notes_controller_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Admin::AccountModerationNotesController, type: :controller do let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: '' } } } it 'falls to create a note' do - expect { subject }.not_to change { AccountModerationNote.count } + expect { subject }.to_not change { AccountModerationNote.count } expect(subject).to render_template 'admin/accounts/show' end end diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 48204b7b6..35d79740a 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -84,7 +84,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to memorialize account' do is_expected.to have_http_status :forbidden - expect(account.reload).not_to be_memorial + expect(account.reload).to_not be_memorial end end @@ -106,7 +106,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to memorialize account' do is_expected.to have_http_status :forbidden - expect(account.reload).not_to be_memorial + expect(account.reload).to_not be_memorial end end @@ -115,7 +115,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to memorialize account' do is_expected.to have_http_status :forbidden - expect(account.reload).not_to be_memorial + expect(account.reload).to_not be_memorial end end end @@ -133,7 +133,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'succeeds in enabling account' do is_expected.to redirect_to admin_account_path(account.id) - expect(user.reload).not_to be_disabled + expect(user.reload).to_not be_disabled end end @@ -183,7 +183,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to approve account' do is_expected.to have_http_status :forbidden - expect(user.reload).not_to be_approved + expect(user.reload).to_not be_approved end end end @@ -223,7 +223,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'fails to reject account' do is_expected.to have_http_status :forbidden - expect(user.reload).not_to be_approved + expect(user.reload).to_not be_approved end end end diff --git a/spec/controllers/admin/change_email_controller_spec.rb b/spec/controllers/admin/change_email_controller_spec.rb index 0814f327d..520842a19 100644 --- a/spec/controllers/admin/change_email_controller_spec.rb +++ b/spec/controllers/admin/change_email_controller_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do expect(user.email).to eq previous_email expect(user.unconfirmed_email).to eq 'test@example.com' - expect(user.confirmation_token).not_to be_nil + expect(user.confirmation_token).to_not be_nil expect(UserMailer).to have_received(:confirmation_instructions).with(user, user.confirmation_token, { to: 'test@example.com' }) diff --git a/spec/controllers/admin/confirmations_controller_spec.rb b/spec/controllers/admin/confirmations_controller_spec.rb index 6268903c4..7ca90f3e1 100644 --- a/spec/controllers/admin/confirmations_controller_spec.rb +++ b/spec/controllers/admin/confirmations_controller_spec.rb @@ -55,7 +55,7 @@ RSpec.describe Admin::ConfirmationsController, type: :controller do it 'does not resend confirmation mail' do expect(subject).to redirect_to admin_accounts_path expect(flash[:error]).to eq I18n.t('admin.accounts.resend_confirmation.already_confirmed') - expect(UserMailer).not_to have_received(:confirmation_instructions) + expect(UserMailer).to_not have_received(:confirmation_instructions) end end end diff --git a/spec/controllers/admin/domain_blocks_controller_spec.rb b/spec/controllers/admin/domain_blocks_controller_spec.rb index 3b2fd6c5d..92fc19efa 100644 --- a/spec/controllers/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/domain_blocks_controller_spec.rb @@ -54,7 +54,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do post :create, params: { domain_block: { domain: 'example.com', severity: 'silence' } } - expect(DomainBlockWorker).not_to have_received(:perform_async) + expect(DomainBlockWorker).to_not have_received(:perform_async) expect(response).to render_template :new end diff --git a/spec/controllers/admin/report_notes_controller_spec.rb b/spec/controllers/admin/report_notes_controller_spec.rb index fa7572d18..8a2603611 100644 --- a/spec/controllers/admin/report_notes_controller_spec.rb +++ b/spec/controllers/admin/report_notes_controller_spec.rb @@ -34,7 +34,7 @@ describe Admin::ReportNotesController do it 'creates a report note and does not resolve report' do expect { subject }.to change { ReportNote.count }.by(1) - expect(report.reload).not_to be_action_taken + expect(report.reload).to_not be_action_taken expect(subject).to redirect_to admin_report_path(report) end end @@ -49,7 +49,7 @@ describe Admin::ReportNotesController do it 'creates a report note and unresolves report' do expect { subject }.to change { ReportNote.count }.by(1) - expect(report.reload).not_to be_action_taken + expect(report.reload).to_not be_action_taken expect(subject).to redirect_to admin_report_path(report) end end diff --git a/spec/controllers/settings/profiles_controller_spec.rb b/spec/controllers/settings/profiles_controller_spec.rb index fbbca8bb9..c7a6ad664 100644 --- a/spec/controllers/settings/profiles_controller_spec.rb +++ b/spec/controllers/settings/profiles_controller_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Settings::ProfilesController, type: :controller do put :update, params: { account: { avatar: fixture_file_upload('avatar.gif', 'image/gif') } } expect(response).to redirect_to(settings_profile_path) - expect(account.reload.avatar.instance.avatar_file_name).not_to be_nil + expect(account.reload.avatar.instance.avatar_file_name).to_not be_nil expect(ActivityPub::UpdateDistributionWorker).to have_received(:perform_async).with(account.id) end end diff --git a/spec/controllers/well_known/nodeinfo_controller_spec.rb b/spec/controllers/well_known/nodeinfo_controller_spec.rb index 964a14706..e9436cd26 100644 --- a/spec/controllers/well_known/nodeinfo_controller_spec.rb +++ b/spec/controllers/well_known/nodeinfo_controller_spec.rb @@ -27,7 +27,7 @@ describe WellKnown::NodeInfoController, type: :controller do json = body_as_json - expect({ 'foo' => 0 }).not_to match_json_schema('nodeinfo_2.0') + expect({ 'foo' => 0 }).to_not match_json_schema('nodeinfo_2.0') expect(json).to match_json_schema('nodeinfo_2.0') expect(json[:version]).to eq '2.0' expect(json[:usage]).to be_a Hash diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb index 461c3757b..adb13acc2 100644 --- a/spec/lib/activitypub/activity/announce_spec.rb +++ b/spec/lib/activitypub/activity/announce_spec.rb @@ -139,7 +139,7 @@ RSpec.describe ActivityPub::Activity::Announce do end it 'does not fetch the remote status' do - expect(a_request(:get, 'https://example.com/actor/hello-world')).not_to have_been_made + expect(a_request(:get, 'https://example.com/actor/hello-world')).to_not have_been_made expect(Status.find_by(uri: 'https://example.com/actor/hello-world')).to be_nil end diff --git a/spec/lib/request_spec.rb b/spec/lib/request_spec.rb index e555a8b5a..f63a836de 100644 --- a/spec/lib/request_spec.rb +++ b/spec/lib/request_spec.rb @@ -102,7 +102,7 @@ describe Request do it 'accepts body less than 1 megabyte by default' do stub_request(:any, 'http://example.com').to_return(body: SecureRandom.random_bytes(2.kilobytes)) - expect { subject.perform { |response| response.body_with_limit } }.not_to raise_error + expect { subject.perform { |response| response.body_with_limit } }.to_not raise_error end it 'rejects body by given size' do diff --git a/spec/lib/status_filter_spec.rb b/spec/lib/status_filter_spec.rb index 287fe00de..cdb482059 100644 --- a/spec/lib/status_filter_spec.rb +++ b/spec/lib/status_filter_spec.rb @@ -10,7 +10,7 @@ describe StatusFilter do subject { described_class.new(status, nil) } context 'when there are no connections' do - it { is_expected.not_to be_filtered } + it { is_expected.to_not be_filtered } end context 'when status account is silenced' do @@ -36,7 +36,7 @@ describe StatusFilter do subject { described_class.new(status, account) } context 'when there are no connections' do - it { is_expected.not_to be_filtered } + it { is_expected.to_not be_filtered } end context 'when status account is blocked' do diff --git a/spec/lib/text_formatter_spec.rb b/spec/lib/text_formatter_spec.rb index d4a3a6b59..cc742b65e 100644 --- a/spec/lib/text_formatter_spec.rb +++ b/spec/lib/text_formatter_spec.rb @@ -18,7 +18,7 @@ RSpec.describe TextFormatter do let(:text) { "line\nfeed" } it 'removes line feeds' do - is_expected.not_to include "\n" + is_expected.to_not include "\n" end end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 763835618..03ed12d78 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Account, type: :model do end it 'does not raise an error' do - expect { subject.suspend! }.not_to raise_error + expect { subject.suspend! }.to_not raise_error end end end @@ -206,7 +206,7 @@ RSpec.describe Account, type: :model do end it 'calls not ResolveAccountService#call' do - expect_any_instance_of(ResolveAccountService).not_to receive(:call).with(acct) + expect_any_instance_of(ResolveAccountService).to_not receive(:call).with(acct) account.refresh! end end @@ -811,19 +811,19 @@ RSpec.describe Account, type: :model do it 'is valid even if the username is longer than 30 characters' do account = Fabricate.build(:account, domain: 'domain', username: Faker::Lorem.characters(number: 31)) account.valid? - expect(account).not_to model_have_error_on_field(:username) + expect(account).to_not model_have_error_on_field(:username) end it 'is valid even if the display name is longer than 30 characters' do account = Fabricate.build(:account, domain: 'domain', display_name: Faker::Lorem.characters(number: 31)) account.valid? - expect(account).not_to model_have_error_on_field(:display_name) + expect(account).to_not model_have_error_on_field(:display_name) end it 'is valid even if the note is longer than 500 characters' do account = Fabricate.build(:account, domain: 'domain', note: Faker::Lorem.characters(number: 501)) account.valid? - expect(account).not_to model_have_error_on_field(:note) + expect(account).to_not model_have_error_on_field(:note) end end end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index b79c44594..b2d84308b 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -163,7 +163,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_a Mute - end.not_to change { mute.reload.hide_notifications? }.from(true) + end.to_not change { mute.reload.hide_notifications? }.from(true) end end @@ -183,7 +183,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_a Mute - end.not_to change { mute.reload.hide_notifications? }.from(true) + end.to_not change { mute.reload.hide_notifications? }.from(true) end end end @@ -207,7 +207,7 @@ describe AccountInteractions do it 'returns Mute without updating mute.hide_notifications' do expect do expect(subject).to be_a Mute - end.not_to change { mute.reload.hide_notifications? }.from(false) + end.to_not change { mute.reload.hide_notifications? }.from(false) end end diff --git a/spec/models/concerns/remotable_spec.rb b/spec/models/concerns/remotable_spec.rb index ca2d65d2d..964520427 100644 --- a/spec/models/concerns/remotable_spec.rb +++ b/spec/models/concerns/remotable_spec.rb @@ -147,8 +147,8 @@ RSpec.describe Remotable do let(:code) { 500 } it 'does not assign file' do - expect(foo).not_to receive(:public_send).with("#{hoge}=", any_args) - expect(foo).not_to receive(:public_send).with("#{hoge}_file_name=", any_args) + expect(foo).to_not receive(:public_send).with("#{hoge}=", any_args) + expect(foo).to_not receive(:public_send).with("#{hoge}_file_name=", any_args) foo.hoge_remote_url = url end diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb index 0ffc343f1..be46639c5 100644 --- a/spec/models/public_feed_spec.rb +++ b/spec/models/public_feed_spec.rb @@ -11,7 +11,7 @@ RSpec.describe PublicFeed, type: :model do private_status = Fabricate(:status, visibility: :private) expect(subject).to include(public_status.id) - expect(subject).not_to include(private_status.id) + expect(subject).to_not include(private_status.id) end it 'does not include replies' do @@ -19,7 +19,7 @@ RSpec.describe PublicFeed, type: :model do reply = Fabricate(:status, in_reply_to_id: status.id) expect(subject).to include(status.id) - expect(subject).not_to include(reply.id) + expect(subject).to_not include(reply.id) end it 'does not include boosts' do @@ -27,7 +27,7 @@ RSpec.describe PublicFeed, type: :model do boost = Fabricate(:status, reblog_of_id: status.id) expect(subject).to include(status.id) - expect(subject).not_to include(boost.id) + expect(subject).to_not include(boost.id) end it 'filters out silenced accounts' do @@ -36,7 +36,7 @@ RSpec.describe PublicFeed, type: :model do silenced_status = Fabricate(:status, account: silenced_account) expect(subject).to include(status.id) - expect(subject).not_to include(silenced_status.id) + expect(subject).to_not include(silenced_status.id) end context 'without local_only option' do @@ -87,7 +87,7 @@ RSpec.describe PublicFeed, type: :model do it 'does not include remote instances statuses' do expect(subject).to include(local_status.id) - expect(subject).not_to include(remote_status.id) + expect(subject).to_not include(remote_status.id) end end @@ -96,13 +96,13 @@ RSpec.describe PublicFeed, type: :model do it 'does not include remote instances statuses' do expect(subject).to include(local_status.id) - expect(subject).not_to include(remote_status.id) + expect(subject).to_not include(remote_status.id) end it 'is not affected by personal domain blocks' do viewer.block_domain!('test.com') expect(subject).to include(local_status.id) - expect(subject).not_to include(remote_status.id) + expect(subject).to_not include(remote_status.id) end end end @@ -119,7 +119,7 @@ RSpec.describe PublicFeed, type: :model do let(:viewer) { nil } it 'does not include local instances statuses' do - expect(subject).not_to include(local_status.id) + expect(subject).to_not include(local_status.id) expect(subject).to include(remote_status.id) end end @@ -128,7 +128,7 @@ RSpec.describe PublicFeed, type: :model do let(:viewer) { Fabricate(:account, username: 'viewer') } it 'does not include local instances statuses' do - expect(subject).not_to include(local_status.id) + expect(subject).to_not include(local_status.id) expect(subject).to include(remote_status.id) end end @@ -146,7 +146,7 @@ RSpec.describe PublicFeed, type: :model do @account.block!(blocked) blocked_status = Fabricate(:status, account: blocked) - expect(subject).not_to include(blocked_status.id) + expect(subject).to_not include(blocked_status.id) end it 'excludes statuses from accounts who have blocked the account' do @@ -154,7 +154,7 @@ RSpec.describe PublicFeed, type: :model do blocker.block!(@account) blocked_status = Fabricate(:status, account: blocker) - expect(subject).not_to include(blocked_status.id) + expect(subject).to_not include(blocked_status.id) end it 'excludes statuses from accounts muted by the account' do @@ -162,7 +162,7 @@ RSpec.describe PublicFeed, type: :model do @account.mute!(muted) muted_status = Fabricate(:status, account: muted) - expect(subject).not_to include(muted_status.id) + expect(subject).to_not include(muted_status.id) end it 'excludes statuses from accounts from personally blocked domains' do @@ -170,7 +170,7 @@ RSpec.describe PublicFeed, type: :model do @account.block_domain!(blocked.domain) blocked_status = Fabricate(:status, account: blocked) - expect(subject).not_to include(blocked_status.id) + expect(subject).to_not include(blocked_status.id) end context 'with language preferences' do @@ -182,7 +182,7 @@ RSpec.describe PublicFeed, type: :model do expect(subject).to include(en_status.id) expect(subject).to include(es_status.id) - expect(subject).not_to include(fr_status.id) + expect(subject).to_not include(fr_status.id) end it 'includes all languages when user does not have a setting' do diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 83ba415a8..077223094 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Setting, type: :model do let(:cache_value) { 'cache-value' } it 'calls not RailsSettings::Base#[]' do - expect(RailsSettings::Base).not_to receive(:[]).with(key) + expect(RailsSettings::Base).to_not receive(:[]).with(key) described_class[key] end @@ -104,7 +104,7 @@ RSpec.describe Setting, type: :model do ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do described_class[key] end - expect(callback).not_to have_received(:call) + expect(callback).to_not have_received(:call) end it 'returns the cached value' do diff --git a/spec/models/tag_spec.rb b/spec/models/tag_spec.rb index 102d2f625..7043449c5 100644 --- a/spec/models/tag_spec.rb +++ b/spec/models/tag_spec.rb @@ -4,15 +4,15 @@ require 'rails_helper' RSpec.describe Tag do describe 'validations' do it 'invalid with #' do - expect(described_class.new(name: '#hello_world')).not_to be_valid + expect(described_class.new(name: '#hello_world')).to_not be_valid end it 'invalid with .' do - expect(described_class.new(name: '.abcdef123')).not_to be_valid + expect(described_class.new(name: '.abcdef123')).to_not be_valid end it 'invalid with spaces' do - expect(described_class.new(name: 'hello world')).not_to be_valid + expect(described_class.new(name: 'hello world')).to_not be_valid end it 'valid with aesthetic' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index dde1503c0..c2f7e99ac 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -159,7 +159,7 @@ RSpec.describe User, type: :model do it 'does not trigger the account.approved Web Hook' do subject - expect(TriggerWebhookWorker).not_to have_received(:perform_async).with('account.approved', 'Account', user.account_id) + expect(TriggerWebhookWorker).to_not have_received(:perform_async).with('account.approved', 'Account', user.account_id) end end @@ -270,7 +270,7 @@ RSpec.describe User, type: :model do it 'does not trigger the account.approved Web Hook' do subject - expect(TriggerWebhookWorker).not_to have_received(:perform_async).with('account.approved', 'Account', user.account_id) + expect(TriggerWebhookWorker).to_not have_received(:perform_async).with('account.approved', 'Account', user.account_id) end end end diff --git a/spec/services/account_search_service_spec.rb b/spec/services/account_search_service_spec.rb index d3b5baad6..45e19d1ef 100644 --- a/spec/services/account_search_service_spec.rb +++ b/spec/services/account_search_service_spec.rb @@ -63,7 +63,7 @@ describe AccountSearchService, type: :service do allow(ResolveAccountService).to receive(:new).and_return(service) results = subject.call('newuser@remote.com', nil, limit: 10, resolve: false) - expect(service).not_to have_received(:call) + expect(service).to_not have_received(:call) end end diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index fbfa6d6c6..d35d9596d 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -39,7 +39,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do end it 'does not process payload' do - expect(ActivityPub::Activity).not_to receive(:factory) + expect(ActivityPub::Activity).to_not receive(:factory) subject.call(json, actor) end end @@ -69,7 +69,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do it 'does not process payload if no signature exists' do expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil) - expect(ActivityPub::Activity).not_to receive(:factory) + expect(ActivityPub::Activity).to_not receive(:factory) subject.call(json, forwarder) end @@ -87,7 +87,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do payload['signature'] = { 'type' => 'RsaSignature2017' } expect_any_instance_of(ActivityPub::LinkedDataSignature).to receive(:verify_actor!).and_return(nil) - expect(ActivityPub::Activity).not_to receive(:factory) + expect(ActivityPub::Activity).to_not receive(:factory) subject.call(json, forwarder) end @@ -206,7 +206,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do end it 'does not process forged payload' do - expect(ActivityPub::Activity).not_to receive(:factory).with( + expect(ActivityPub::Activity).to_not receive(:factory).with( hash_including( 'object' => hash_including( 'id' => 'https://example.com/users/bob/fake-status' @@ -216,7 +216,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do anything ) - expect(ActivityPub::Activity).not_to receive(:factory).with( + expect(ActivityPub::Activity).to_not receive(:factory).with( hash_including( 'object' => hash_including( 'content' => '

puck was here

' diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 5d15f6ffe..ae7db88bf 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -214,11 +214,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end it 'does not create any edits' do - expect { subject.call(status, json) }.not_to change { status.reload.edits.pluck(&:id) } + expect { subject.call(status, json) }.to_not change { status.reload.edits.pluck(&:id) } end it 'does not update the text, spoiler_text or edited_at' do - expect { subject.call(status, json) }.not_to change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] } + expect { subject.call(status, json) }.to_not change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] } end end diff --git a/spec/services/block_domain_service_spec.rb b/spec/services/block_domain_service_spec.rb index 242b02fff..e24e48d41 100644 --- a/spec/services/block_domain_service_spec.rb +++ b/spec/services/block_domain_service_spec.rb @@ -67,9 +67,9 @@ RSpec.describe BlockDomainService, type: :service do end it 'leaves the domains status and attachments, but clears media' do - expect { bad_status1.reload }.not_to raise_error - expect { bad_status2.reload }.not_to raise_error - expect { bad_attachment.reload }.not_to raise_error + expect { bad_status1.reload }.to_not raise_error + expect { bad_status2.reload }.to_not raise_error + expect { bad_attachment.reload }.to_not raise_error expect(bad_attachment.file.exists?).to be false end end diff --git a/spec/services/clear_domain_media_service_spec.rb b/spec/services/clear_domain_media_service_spec.rb index 45b92e2c9..e90faf84d 100644 --- a/spec/services/clear_domain_media_service_spec.rb +++ b/spec/services/clear_domain_media_service_spec.rb @@ -14,9 +14,9 @@ RSpec.describe ClearDomainMediaService, type: :service do end it 'leaves the domains status and attachments, but clears media' do - expect { bad_status1.reload }.not_to raise_error - expect { bad_status2.reload }.not_to raise_error - expect { bad_attachment.reload }.not_to raise_error + expect { bad_status1.reload }.to_not raise_error + expect { bad_status2.reload }.to_not raise_error + expect { bad_attachment.reload }.to_not raise_error expect(bad_attachment.file.exists?).to be false end end diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index a12148833..2b1516ff0 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -234,7 +234,7 @@ RSpec.describe ImportService, type: :service do subject.call(import) expect(account.bookmarks.map(&:status).map(&:id)).to include(local_status.id) expect(account.bookmarks.map(&:status).map(&:id)).to include(remote_status.id) - expect(account.bookmarks.map(&:status).map(&:id)).not_to include(direct_status.id) + expect(account.bookmarks.map(&:status).map(&:id)).to_not include(direct_status.id) expect(account.bookmarks.count).to eq 3 end end diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 0b72253a5..2148f1819 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -50,7 +50,7 @@ RSpec.describe PostStatusService, type: :service do end it 'does not change statuses count' do - expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.not_to change { [account.statuses_count, previous_status.replies_count] } + expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not change { [account.statuses_count, previous_status.replies_count] } end end @@ -157,7 +157,7 @@ RSpec.describe PostStatusService, type: :service do expect do subject.call(account, text: '@alice @alice @alice hey @alice') - end.not_to raise_error + end.to_not raise_error end it 'processes hashtags' do diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 6f32007e8..7ec334a56 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -13,8 +13,8 @@ describe SearchService, type: :service do results = subject.call('', nil, 10) expect(results).to eq(empty_results) - expect(AccountSearchService).not_to have_received(:new) - expect(Tag).not_to have_received(:search_for) + expect(AccountSearchService).to_not have_received(:new) + expect(Tag).to_not have_received(:search_for) end end @@ -89,7 +89,7 @@ describe SearchService, type: :service do allow(Tag).to receive(:search_for) results = subject.call(query, nil, 10) - expect(Tag).not_to have_received(:search_for) + expect(Tag).to_not have_received(:search_for) expect(results).to eq empty_results end diff --git a/spec/validators/blacklisted_email_validator_spec.rb b/spec/validators/blacklisted_email_validator_spec.rb index f9ee3b932..cb807fe24 100644 --- a/spec/validators/blacklisted_email_validator_spec.rb +++ b/spec/validators/blacklisted_email_validator_spec.rb @@ -26,7 +26,7 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do let(:blocked_email) { false } it 'does not add errors' do - expect(subject).not_to have_received(:add).with(:email, :blocked) + expect(subject).to_not have_received(:add).with(:email, :blocked) end context 'when canonical e-mail is blocked' do diff --git a/spec/validators/disallowed_hashtags_validator_spec.rb b/spec/validators/disallowed_hashtags_validator_spec.rb index 9deec0bb9..2c4ebc4f2 100644 --- a/spec/validators/disallowed_hashtags_validator_spec.rb +++ b/spec/validators/disallowed_hashtags_validator_spec.rb @@ -19,7 +19,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do let(:reblog) { true } it 'does not add errors' do - expect(errors).not_to have_received(:add).with(:text, any_args) + expect(errors).to_not have_received(:add).with(:text, any_args) end end @@ -31,7 +31,7 @@ RSpec.describe DisallowedHashtagsValidator, type: :validator do let(:disallowed_tags) { [] } it 'does not add errors' do - expect(errors).not_to have_received(:add).with(:text, any_args) + expect(errors).to_not have_received(:add).with(:text, any_args) end end diff --git a/spec/validators/email_mx_validator_spec.rb b/spec/validators/email_mx_validator_spec.rb index 6640d6058..ffb6851d0 100644 --- a/spec/validators/email_mx_validator_spec.rb +++ b/spec/validators/email_mx_validator_spec.rb @@ -38,7 +38,7 @@ describe EmailMxValidator do allow(Resolv::DNS).to receive(:open).and_yield(resolver) subject.validate(user) - expect(user.errors).not_to have_received(:add) + expect(user.errors).to_not have_received(:add) end it 'adds an error if the email domain name contains empty labels' do diff --git a/spec/validators/follow_limit_validator_spec.rb b/spec/validators/follow_limit_validator_spec.rb index cc8fbb631..94ba0c47f 100644 --- a/spec/validators/follow_limit_validator_spec.rb +++ b/spec/validators/follow_limit_validator_spec.rb @@ -22,7 +22,7 @@ RSpec.describe FollowLimitValidator, type: :validator do let(:_nil) { true } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(:base, any_args) + expect(errors).to_not have_received(:add).with(:base, any_args) end end @@ -43,7 +43,7 @@ RSpec.describe FollowLimitValidator, type: :validator do let(:limit_reached) { false } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(:base, any_args) + expect(errors).to_not have_received(:add).with(:base, any_args) end end end diff --git a/spec/validators/poll_validator_spec.rb b/spec/validators/poll_validator_spec.rb index a76c63ccc..f3f4b1288 100644 --- a/spec/validators/poll_validator_spec.rb +++ b/spec/validators/poll_validator_spec.rb @@ -15,14 +15,14 @@ RSpec.describe PollValidator, type: :validator do let(:expires_at) { 1.day.from_now } it 'have no errors' do - expect(errors).not_to have_received(:add) + expect(errors).to_not have_received(:add) end context 'expires just 5 min ago' do let(:expires_at) { 5.minutes.from_now } it 'not calls errors add' do - expect(errors).not_to have_received(:add) + expect(errors).to_not have_received(:add) end end end diff --git a/spec/validators/status_length_validator_spec.rb b/spec/validators/status_length_validator_spec.rb index db9c728a8..e132b5618 100644 --- a/spec/validators/status_length_validator_spec.rb +++ b/spec/validators/status_length_validator_spec.rb @@ -7,13 +7,13 @@ describe StatusLengthValidator do it 'does not add errors onto remote statuses' do status = double(local?: false) subject.validate(status) - expect(status).not_to receive(:errors) + expect(status).to_not receive(:errors) end it 'does not add errors onto local reblogs' do status = double(local?: false, reblog?: true) subject.validate(status) - expect(status).not_to receive(:errors) + expect(status).to_not receive(:errors) end it 'adds an error when content warning is over 500 characters' do diff --git a/spec/validators/unreserved_username_validator_spec.rb b/spec/validators/unreserved_username_validator_spec.rb index e2f051b08..3c6f71c59 100644 --- a/spec/validators/unreserved_username_validator_spec.rb +++ b/spec/validators/unreserved_username_validator_spec.rb @@ -17,7 +17,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do let(:username) { nil } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(:username, any_args) + expect(errors).to_not have_received(:add).with(:username, any_args) end end @@ -36,7 +36,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do let(:reserved_username) { false } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(:username, any_args) + expect(errors).to_not have_received(:add).with(:username, any_args) end end end diff --git a/spec/validators/url_validator_spec.rb b/spec/validators/url_validator_spec.rb index 85eadeb63..966261b50 100644 --- a/spec/validators/url_validator_spec.rb +++ b/spec/validators/url_validator_spec.rb @@ -27,7 +27,7 @@ RSpec.describe URLValidator, type: :validator do let(:compliant) { true } it 'not calls errors.add' do - expect(errors).not_to have_received(:add).with(attribute, any_args) + expect(errors).to_not have_received(:add).with(attribute, any_args) end end end diff --git a/spec/workers/feed_insert_worker_spec.rb b/spec/workers/feed_insert_worker_spec.rb index fb34970fc..1a723d63a 100644 --- a/spec/workers/feed_insert_worker_spec.rb +++ b/spec/workers/feed_insert_worker_spec.rb @@ -16,7 +16,7 @@ describe FeedInsertWorker do result = subject.perform(nil, follower.id) expect(result).to eq true - expect(instance).not_to have_received(:push_to_home) + expect(instance).to_not have_received(:push_to_home) end it 'skips push with missing account' do @@ -25,7 +25,7 @@ describe FeedInsertWorker do result = subject.perform(status.id, nil) expect(result).to eq true - expect(instance).not_to have_received(:push_to_home) + expect(instance).to_not have_received(:push_to_home) end end @@ -36,7 +36,7 @@ describe FeedInsertWorker do result = subject.perform(status.id, follower.id) expect(result).to be_nil - expect(instance).not_to have_received(:push_to_home) + expect(instance).to_not have_received(:push_to_home) end it 'pushes the status onto the home timeline without filter' do -- cgit From bd1d57c2303b7a5df1af749d8851c9364a044e77 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 20:46:00 -0500 Subject: Autofix Rubocop RSpec/EmptyLineAfterSubject (#23719) --- .rubocop_todo.yml | 21 --------------------- .../activitypub/collections_controller_spec.rb | 1 + .../followers_synchronizations_controller_spec.rb | 1 + .../activitypub/outboxes_controller_spec.rb | 1 + .../activitypub/replies_controller_spec.rb | 1 + .../admin/reports/actions_controller_spec.rb | 2 ++ spec/controllers/api/web/embeds_controller_spec.rb | 1 + spec/controllers/emojis_controller_spec.rb | 1 + .../follower_accounts_controller_spec.rb | 1 + .../following_accounts_controller_spec.rb | 1 + spec/controllers/relationships_controller_spec.rb | 1 + spec/lib/activitypub/activity/delete_spec.rb | 2 ++ spec/lib/activitypub/activity/flag_spec.rb | 1 + spec/models/admin/account_action_spec.rb | 1 + spec/models/user_spec.rb | 2 ++ spec/services/fetch_remote_status_service_spec.rb | 1 + spec/workers/refollow_worker_spec.rb | 1 + 17 files changed, 19 insertions(+), 21 deletions(-) (limited to 'spec/controllers/activitypub/collections_controller_spec.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e33d1d745..02f84e70f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -817,27 +817,6 @@ RSpec/EmptyExampleGroup: - 'spec/models/web/setting_spec.rb' - 'spec/services/unmute_service_spec.rb' -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterSubject: - Exclude: - - 'spec/controllers/activitypub/collections_controller_spec.rb' - - 'spec/controllers/activitypub/followers_synchronizations_controller_spec.rb' - - 'spec/controllers/activitypub/outboxes_controller_spec.rb' - - 'spec/controllers/activitypub/replies_controller_spec.rb' - - 'spec/controllers/admin/reports/actions_controller_spec.rb' - - 'spec/controllers/api/web/embeds_controller_spec.rb' - - 'spec/controllers/emojis_controller_spec.rb' - - 'spec/controllers/follower_accounts_controller_spec.rb' - - 'spec/controllers/following_accounts_controller_spec.rb' - - 'spec/controllers/relationships_controller_spec.rb' - - 'spec/lib/activitypub/activity/delete_spec.rb' - - 'spec/lib/activitypub/activity/flag_spec.rb' - - 'spec/models/admin/account_action_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/services/fetch_remote_status_service_spec.rb' - - 'spec/workers/refollow_worker_spec.rb' - # Offense count: 178 # Configuration parameters: CountAsOne. RSpec/ExampleLength: diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index bf81cdb93..19c0e0a64 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -38,6 +38,7 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do let(:remote_account) { nil } subject(:response) { get :show, params: { id: 'featured', account_username: account.username } } + subject(:body) { body_as_json } it 'returns http success' do diff --git a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb index c19bb8cae..893c8e14f 100644 --- a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb +++ b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb @@ -35,6 +35,7 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controll let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') } subject(:response) { get :show, params: { account_username: account.username } } + subject(:body) { body_as_json } it 'returns http success' do diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb index d8d42b7ae..f84a902ea 100644 --- a/spec/controllers/activitypub/outboxes_controller_spec.rb +++ b/spec/controllers/activitypub/outboxes_controller_spec.rb @@ -36,6 +36,7 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do let(:remote_account) { nil } subject(:response) { get :show, params: { account_username: account.username, page: page } } + subject(:body) { body_as_json } context 'with page not requested' do diff --git a/spec/controllers/activitypub/replies_controller_spec.rb b/spec/controllers/activitypub/replies_controller_spec.rb index 394d4baab..582ef863f 100644 --- a/spec/controllers/activitypub/replies_controller_spec.rb +++ b/spec/controllers/activitypub/replies_controller_spec.rb @@ -181,6 +181,7 @@ RSpec.describe ActivityPub::RepliesController, type: :controller do describe 'GET #index' do subject(:response) { get :index, params: { account_username: status.account.username, status_id: status.id, only_other_accounts: only_other_accounts } } + let(:only_other_accounts) { nil } context 'with no signature' do diff --git a/spec/controllers/admin/reports/actions_controller_spec.rb b/spec/controllers/admin/reports/actions_controller_spec.rb index 9890ac9ce..db3a1d311 100644 --- a/spec/controllers/admin/reports/actions_controller_spec.rb +++ b/spec/controllers/admin/reports/actions_controller_spec.rb @@ -123,11 +123,13 @@ describe Admin::Reports::ActionsController do context 'action as submit button' do subject { post :create, params: { report_id: report.id, text: text, action => '' } } + it_behaves_like 'all action types' end context 'action as submit button' do subject { post :create, params: { report_id: report.id, text: text, moderation_action: action } } + it_behaves_like 'all action types' end end diff --git a/spec/controllers/api/web/embeds_controller_spec.rb b/spec/controllers/api/web/embeds_controller_spec.rb index 345c317ba..b3ef73915 100644 --- a/spec/controllers/api/web/embeds_controller_spec.rb +++ b/spec/controllers/api/web/embeds_controller_spec.rb @@ -11,6 +11,7 @@ describe Api::Web::EmbedsController do describe 'POST #create' do subject(:response) { post :create, params: { url: url } } + subject(:body) { JSON.parse(response.body, symbolize_names: true) } context 'when successfully finds status' do diff --git a/spec/controllers/emojis_controller_spec.rb b/spec/controllers/emojis_controller_spec.rb index fbbd11f64..9f6604964 100644 --- a/spec/controllers/emojis_controller_spec.rb +++ b/spec/controllers/emojis_controller_spec.rb @@ -7,6 +7,7 @@ describe EmojisController do describe 'GET #show' do subject(:response) { get :show, params: { id: emoji.id, format: :json } } + subject(:body) { JSON.parse(response.body, symbolize_names: true) } it 'returns the right response' do diff --git a/spec/controllers/follower_accounts_controller_spec.rb b/spec/controllers/follower_accounts_controller_spec.rb index ab2e82e85..43fc4203c 100644 --- a/spec/controllers/follower_accounts_controller_spec.rb +++ b/spec/controllers/follower_accounts_controller_spec.rb @@ -38,6 +38,7 @@ describe FollowerAccountsController do context 'when format is json' do subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } + subject(:body) { JSON.parse(response.body) } context 'with page' do diff --git a/spec/controllers/following_accounts_controller_spec.rb b/spec/controllers/following_accounts_controller_spec.rb index e43dbf882..b41bf0575 100644 --- a/spec/controllers/following_accounts_controller_spec.rb +++ b/spec/controllers/following_accounts_controller_spec.rb @@ -38,6 +38,7 @@ describe FollowingAccountsController do context 'when format is json' do subject(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } + subject(:body) { JSON.parse(response.body) } context 'with page' do diff --git a/spec/controllers/relationships_controller_spec.rb b/spec/controllers/relationships_controller_spec.rb index 2056a2ac2..cd09cf50b 100644 --- a/spec/controllers/relationships_controller_spec.rb +++ b/spec/controllers/relationships_controller_spec.rb @@ -51,6 +51,7 @@ describe RelationshipsController do context 'when select parameter is not provided' do subject { patch :update } + include_examples 'redirects back to followers page' end diff --git a/spec/lib/activitypub/activity/delete_spec.rb b/spec/lib/activitypub/activity/delete_spec.rb index 9dfb8a61b..40cd0fce9 100644 --- a/spec/lib/activitypub/activity/delete_spec.rb +++ b/spec/lib/activitypub/activity/delete_spec.rb @@ -30,6 +30,7 @@ RSpec.describe ActivityPub::Activity::Delete do context 'when the status has been reblogged' do describe '#perform' do subject { described_class.new(json, sender) } + let!(:reblogger) { Fabricate(:account) } let!(:follower) { Fabricate(:account, username: 'follower', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } let!(:reblog) { Fabricate(:status, account: reblogger, reblog: status) } @@ -53,6 +54,7 @@ RSpec.describe ActivityPub::Activity::Delete do context 'when the status has been reported' do describe '#perform' do subject { described_class.new(json, sender) } + let!(:reporter) { Fabricate(:account) } before do diff --git a/spec/lib/activitypub/activity/flag_spec.rb b/spec/lib/activitypub/activity/flag_spec.rb index 7890fd1e8..c2a505356 100644 --- a/spec/lib/activitypub/activity/flag_spec.rb +++ b/spec/lib/activitypub/activity/flag_spec.rb @@ -110,6 +110,7 @@ RSpec.describe ActivityPub::Activity::Flag do describe '#perform with a defined uri' do subject { described_class.new(json, sender) } + let(:flag_id) { 'http://example.com/reports/1' } before do diff --git a/spec/models/admin/account_action_spec.rb b/spec/models/admin/account_action_spec.rb index b6a052b76..4516df2c2 100644 --- a/spec/models/admin/account_action_spec.rb +++ b/spec/models/admin/account_action_spec.rb @@ -5,6 +5,7 @@ RSpec.describe Admin::AccountAction, type: :model do describe '#save!' do subject { account_action.save! } + let(:account) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account } let(:target_account) { Fabricate(:account) } let(:type) { 'disable' } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c2f7e99ac..d23439f1a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -409,6 +409,7 @@ RSpec.describe User, type: :model do describe '#disable!' do subject(:user) { Fabricate(:user, disabled: false, current_sign_in_at: current_sign_in_at, last_sign_in_at: nil) } + let(:current_sign_in_at) { Time.zone.now } before do @@ -497,6 +498,7 @@ RSpec.describe User, type: :model do describe '#active_for_authentication?' do subject { user.active_for_authentication? } + let(:user) { Fabricate(:user, disabled: disabled, confirmed_at: confirmed_at) } context 'when user is disabled' do diff --git a/spec/services/fetch_remote_status_service_spec.rb b/spec/services/fetch_remote_status_service_spec.rb index 02c62f8d6..ace520b8f 100644 --- a/spec/services/fetch_remote_status_service_spec.rb +++ b/spec/services/fetch_remote_status_service_spec.rb @@ -16,6 +16,7 @@ RSpec.describe FetchRemoteStatusService, type: :service do context 'protocol is :activitypub' do subject { described_class.new.call(note[:id], prefetched_body: prefetched_body) } + let(:prefetched_body) { Oj.dump(note) } before do diff --git a/spec/workers/refollow_worker_spec.rb b/spec/workers/refollow_worker_spec.rb index d9c2293b6..1dac15385 100644 --- a/spec/workers/refollow_worker_spec.rb +++ b/spec/workers/refollow_worker_spec.rb @@ -4,6 +4,7 @@ require 'rails_helper' describe RefollowWorker do subject { described_class.new } + let(:account) { Fabricate(:account, domain: 'example.org', protocol: :activitypub) } let(:alice) { Fabricate(:account, domain: nil, username: 'alice') } let(:bob) { Fabricate(:account, domain: nil, username: 'bob') } -- cgit From 4552685f6bd400666ec4058783eeabb11568e575 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sun, 19 Feb 2023 23:24:14 -0500 Subject: Autofix Rubocop RSpec/LeadingSubject (#23670) --- .rubocop_todo.yml | 82 ---------------------- .../activitypub/collections_controller_spec.rb | 4 +- .../followers_synchronizations_controller_spec.rb | 4 +- .../activitypub/inboxes_controller_spec.rb | 4 +- .../activitypub/outboxes_controller_spec.rb | 4 +- spec/controllers/admin/invites_controller_spec.rb | 4 +- .../auth/registrations_controller_spec.rb | 64 ++++++++--------- .../well_known/webfinger_controller_spec.rb | 8 +-- spec/lib/activitypub/activity/accept_spec.rb | 4 +- spec/lib/activitypub/activity/announce_spec.rb | 8 +-- spec/lib/activitypub/activity/create_spec.rb | 16 ++--- spec/lib/activitypub/activity/reject_spec.rb | 4 +- spec/lib/activitypub/activity/undo_spec.rb | 4 +- spec/lib/activitypub/activity/update_spec.rb | 4 +- spec/lib/activitypub/adapter_spec.rb | 4 +- spec/lib/activitypub/dereferencer_spec.rb | 4 +- spec/lib/activitypub/linked_data_signature_spec.rb | 4 +- spec/lib/link_details_extractor_spec.rb | 4 +- spec/lib/status_filter_spec.rb | 4 +- spec/lib/status_reach_finder_spec.rb | 4 +- spec/lib/suspicious_sign_in_detector_spec.rb | 4 +- spec/lib/text_formatter_spec.rb | 4 +- spec/lib/vacuum/backups_vacuum_spec.rb | 4 +- spec/lib/vacuum/media_attachments_vacuum_spec.rb | 4 +- spec/lib/vacuum/preview_cards_vacuum_spec.rb | 4 +- spec/lib/vacuum/statuses_vacuum_spec.rb | 4 +- spec/models/account/field_spec.rb | 12 ++-- spec/models/account_spec.rb | 16 ++--- .../models/account_statuses_cleanup_policy_spec.rb | 20 +++--- spec/models/account_statuses_filter_spec.rb | 4 +- spec/models/concerns/account_interactions_spec.rb | 40 +++++------ spec/models/custom_emoji_filter_spec.rb | 4 +- spec/models/custom_emoji_spec.rb | 12 ++-- spec/models/home_feed_spec.rb | 4 +- spec/models/media_attachment_spec.rb | 8 +-- spec/models/public_feed_spec.rb | 16 ++--- spec/models/remote_follow_spec.rb | 4 +- spec/models/setting_spec.rb | 4 +- spec/models/status_spec.rb | 16 ++--- spec/models/user_spec.rb | 4 +- spec/models/web/push_subscription_spec.rb | 4 +- .../familiar_followers_presenter_spec.rb | 4 +- spec/serializers/activitypub/note_spec.rb | 4 +- spec/serializers/activitypub/update_poll_spec.rb | 4 +- spec/serializers/rest/account_serializer_spec.rb | 4 +- .../fetch_featured_collection_service_spec.rb | 4 +- .../fetch_featured_tags_collection_service_spec.rb | 4 +- .../fetch_remote_status_service_spec.rb | 4 +- .../activitypub/fetch_replies_service_spec.rb | 4 +- .../activitypub/process_account_service_spec.rb | 8 +-- .../activitypub/process_collection_service_spec.rb | 4 +- .../process_status_update_service_spec.rb | 4 +- .../synchronize_followers_service_spec.rb | 4 +- ...after_block_domain_from_account_service_spec.rb | 4 +- spec/services/app_sign_up_service_spec.rb | 4 +- spec/services/authorize_follow_service_spec.rb | 4 +- spec/services/block_domain_service_spec.rb | 4 +- spec/services/block_service_spec.rb | 4 +- spec/services/clear_domain_media_service_spec.rb | 4 +- spec/services/delete_account_service_spec.rb | 4 +- spec/services/fan_out_on_write_service_spec.rb | 4 +- spec/services/favourite_service_spec.rb | 4 +- spec/services/fetch_resource_service_spec.rb | 4 +- spec/services/follow_service_spec.rb | 4 +- spec/services/process_mentions_service_spec.rb | 4 +- spec/services/purge_domain_service_spec.rb | 4 +- spec/services/reblog_service_spec.rb | 8 +-- spec/services/reject_follow_service_spec.rb | 4 +- spec/services/remove_from_follwers_service_spec.rb | 4 +- spec/services/report_service_spec.rb | 12 ++-- spec/services/suspend_account_service_spec.rb | 4 +- spec/services/unallow_domain_service_spec.rb | 4 +- spec/services/unblock_service_spec.rb | 4 +- spec/services/unfollow_service_spec.rb | 4 +- spec/services/unsuspend_account_service_spec.rb | 4 +- .../validators/blacklisted_email_validator_spec.rb | 4 +- spec/workers/move_worker_spec.rb | 4 +- spec/workers/unfollow_follow_worker_spec.rb | 4 +- 78 files changed, 256 insertions(+), 338 deletions(-) (limited to 'spec/controllers/activitypub/collections_controller_spec.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index eb0910fe6..1eb039110 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -952,88 +952,6 @@ RSpec/InstanceVariable: - 'spec/services/search_service_spec.rb' - 'spec/services/unblock_domain_service_spec.rb' -# Offense count: 118 -# This cop supports safe autocorrection (--autocorrect). -RSpec/LeadingSubject: - Exclude: - - 'spec/controllers/activitypub/collections_controller_spec.rb' - - 'spec/controllers/activitypub/followers_synchronizations_controller_spec.rb' - - 'spec/controllers/activitypub/inboxes_controller_spec.rb' - - 'spec/controllers/activitypub/outboxes_controller_spec.rb' - - 'spec/controllers/admin/invites_controller_spec.rb' - - 'spec/controllers/auth/registrations_controller_spec.rb' - - 'spec/controllers/well_known/webfinger_controller_spec.rb' - - 'spec/lib/activitypub/activity/accept_spec.rb' - - 'spec/lib/activitypub/activity/announce_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - - 'spec/lib/activitypub/activity/reject_spec.rb' - - 'spec/lib/activitypub/activity/undo_spec.rb' - - 'spec/lib/activitypub/activity/update_spec.rb' - - 'spec/lib/activitypub/adapter_spec.rb' - - 'spec/lib/activitypub/dereferencer_spec.rb' - - 'spec/lib/activitypub/linked_data_signature_spec.rb' - - 'spec/lib/link_details_extractor_spec.rb' - - 'spec/lib/status_filter_spec.rb' - - 'spec/lib/status_reach_finder_spec.rb' - - 'spec/lib/suspicious_sign_in_detector_spec.rb' - - 'spec/lib/text_formatter_spec.rb' - - 'spec/lib/vacuum/backups_vacuum_spec.rb' - - 'spec/lib/vacuum/media_attachments_vacuum_spec.rb' - - 'spec/lib/vacuum/preview_cards_vacuum_spec.rb' - - 'spec/lib/vacuum/statuses_vacuum_spec.rb' - - 'spec/models/account/field_spec.rb' - - 'spec/models/account_spec.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/models/account_statuses_filter_spec.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - - 'spec/models/custom_emoji_filter_spec.rb' - - 'spec/models/custom_emoji_spec.rb' - - 'spec/models/home_feed_spec.rb' - - 'spec/models/media_attachment_spec.rb' - - 'spec/models/public_feed_spec.rb' - - 'spec/models/remote_follow_spec.rb' - - 'spec/models/setting_spec.rb' - - 'spec/models/status_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/models/web/push_subscription_spec.rb' - - 'spec/presenters/familiar_followers_presenter_spec.rb' - - 'spec/serializers/activitypub/note_spec.rb' - - 'spec/serializers/activitypub/update_poll_spec.rb' - - 'spec/serializers/rest/account_serializer_spec.rb' - - 'spec/services/activitypub/fetch_featured_collection_service_spec.rb' - - 'spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb' - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/services/activitypub/fetch_replies_service_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/activitypub/synchronize_followers_service_spec.rb' - - 'spec/services/after_block_domain_from_account_service_spec.rb' - - 'spec/services/app_sign_up_service_spec.rb' - - 'spec/services/authorize_follow_service_spec.rb' - - 'spec/services/block_domain_service_spec.rb' - - 'spec/services/block_service_spec.rb' - - 'spec/services/clear_domain_media_service_spec.rb' - - 'spec/services/delete_account_service_spec.rb' - - 'spec/services/fan_out_on_write_service_spec.rb' - - 'spec/services/favourite_service_spec.rb' - - 'spec/services/fetch_resource_service_spec.rb' - - 'spec/services/follow_service_spec.rb' - - 'spec/services/process_mentions_service_spec.rb' - - 'spec/services/purge_domain_service_spec.rb' - - 'spec/services/reblog_service_spec.rb' - - 'spec/services/reject_follow_service_spec.rb' - - 'spec/services/remove_from_follwers_service_spec.rb' - - 'spec/services/report_service_spec.rb' - - 'spec/services/suspend_account_service_spec.rb' - - 'spec/services/unallow_domain_service_spec.rb' - - 'spec/services/unblock_service_spec.rb' - - 'spec/services/unfollow_service_spec.rb' - - 'spec/services/unsuspend_account_service_spec.rb' - - 'spec/validators/blacklisted_email_validator_spec.rb' - - 'spec/workers/move_worker_spec.rb' - - 'spec/workers/unfollow_follow_worker_spec.rb' - # Offense count: 15 RSpec/LeakyConstantDeclaration: Exclude: diff --git a/spec/controllers/activitypub/collections_controller_spec.rb b/spec/controllers/activitypub/collections_controller_spec.rb index 19c0e0a64..77901131e 100644 --- a/spec/controllers/activitypub/collections_controller_spec.rb +++ b/spec/controllers/activitypub/collections_controller_spec.rb @@ -35,11 +35,11 @@ RSpec.describe ActivityPub::CollectionsController, type: :controller do describe 'GET #show' do context 'when id is "featured"' do context 'without signature' do - let(:remote_account) { nil } + subject(:body) { body_as_json } subject(:response) { get :show, params: { id: 'featured', account_username: account.username } } - subject(:body) { body_as_json } + let(:remote_account) { nil } it 'returns http success' do expect(response).to have_http_status(200) diff --git a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb index 893c8e14f..6ec756d3c 100644 --- a/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb +++ b/spec/controllers/activitypub/followers_synchronizations_controller_spec.rb @@ -32,11 +32,11 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController, type: :controll end context 'with signature from example.com' do - let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') } + subject(:body) { body_as_json } subject(:response) { get :show, params: { account_username: account.username } } - subject(:body) { body_as_json } + let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') } it 'returns http success' do expect(response).to have_http_status(200) diff --git a/spec/controllers/activitypub/inboxes_controller_spec.rb b/spec/controllers/activitypub/inboxes_controller_spec.rb index 7f4d6b2d3..8d4084648 100644 --- a/spec/controllers/activitypub/inboxes_controller_spec.rb +++ b/spec/controllers/activitypub/inboxes_controller_spec.rb @@ -22,10 +22,10 @@ RSpec.describe ActivityPub::InboxesController, type: :controller do end context 'for a specific account' do - let(:account) { Fabricate(:account) } - subject(:response) { post :create, params: { account_username: account.username }, body: '{}' } + let(:account) { Fabricate(:account) } + context 'when account is permanently suspended' do before do account.suspend! diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb index f84a902ea..7369ee413 100644 --- a/spec/controllers/activitypub/outboxes_controller_spec.rb +++ b/spec/controllers/activitypub/outboxes_controller_spec.rb @@ -33,11 +33,11 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do describe 'GET #show' do context 'without signature' do - let(:remote_account) { nil } + subject(:body) { body_as_json } subject(:response) { get :show, params: { account_username: account.username, page: page } } - subject(:body) { body_as_json } + let(:remote_account) { nil } context 'with page not requested' do let(:page) { nil } diff --git a/spec/controllers/admin/invites_controller_spec.rb b/spec/controllers/admin/invites_controller_spec.rb index 1fb488742..92ec4e449 100644 --- a/spec/controllers/admin/invites_controller_spec.rb +++ b/spec/controllers/admin/invites_controller_spec.rb @@ -33,10 +33,10 @@ describe Admin::InvitesController do end describe 'DELETE #destroy' do - let!(:invite) { Fabricate(:invite, expires_at: nil) } - subject { delete :destroy, params: { id: invite.id } } + let!(:invite) { Fabricate(:invite, expires_at: nil) } + it 'expires invite' do expect(subject).to redirect_to admin_invites_path expect(invite.reload).to be_expired diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index 52023eb2e..8cfb8e277 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -95,18 +95,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do before { request.env['devise.mapping'] = Devise.mappings[:user] } context do - around do |example| - registrations_mode = Setting.registrations_mode - example.run - Setting.registrations_mode = registrations_mode - end - subject do Setting.registrations_mode = 'open' request.headers['Accept-Language'] = accept_language post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } } end + around do |example| + registrations_mode = Setting.registrations_mode + example.run + Setting.registrations_mode = registrations_mode + end + it 'redirects to setup' do subject expect(response).to redirect_to auth_setup_path @@ -121,18 +121,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end context 'when user has not agreed to terms of service' do - around do |example| - registrations_mode = Setting.registrations_mode - example.run - Setting.registrations_mode = registrations_mode - end - subject do Setting.registrations_mode = 'open' request.headers['Accept-Language'] = accept_language post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'false' } } end + around do |example| + registrations_mode = Setting.registrations_mode + example.run + Setting.registrations_mode = registrations_mode + end + it 'does not create user' do subject user = User.find_by(email: 'test@example.com') @@ -141,18 +141,18 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end context 'approval-based registrations without invite' do - around do |example| - registrations_mode = Setting.registrations_mode - example.run - Setting.registrations_mode = registrations_mode - end - subject do Setting.registrations_mode = 'approved' request.headers['Accept-Language'] = accept_language post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', agreement: 'true' } } end + around do |example| + registrations_mode = Setting.registrations_mode + example.run + Setting.registrations_mode = registrations_mode + end + it 'redirects to setup' do subject expect(response).to redirect_to auth_setup_path @@ -168,12 +168,6 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end context 'approval-based registrations with expired invite' do - around do |example| - registrations_mode = Setting.registrations_mode - example.run - Setting.registrations_mode = registrations_mode - end - subject do Setting.registrations_mode = 'approved' request.headers['Accept-Language'] = accept_language @@ -181,6 +175,12 @@ RSpec.describe Auth::RegistrationsController, type: :controller do post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } } end + around do |example| + registrations_mode = Setting.registrations_mode + example.run + Setting.registrations_mode = registrations_mode + end + it 'redirects to setup' do subject expect(response).to redirect_to auth_setup_path @@ -196,14 +196,6 @@ RSpec.describe Auth::RegistrationsController, type: :controller do end context 'approval-based registrations with valid invite and required invite text' do - around do |example| - registrations_mode = Setting.registrations_mode - require_invite_text = Setting.require_invite_text - example.run - Setting.require_invite_text = require_invite_text - Setting.registrations_mode = registrations_mode - end - subject do inviter = Fabricate(:user, confirmed_at: 2.days.ago) Setting.registrations_mode = 'approved' @@ -213,6 +205,14 @@ RSpec.describe Auth::RegistrationsController, type: :controller do post :create, params: { user: { account_attributes: { username: 'test' }, email: 'test@example.com', password: '12345678', password_confirmation: '12345678', invite_code: invite.code, agreement: 'true' } } end + around do |example| + registrations_mode = Setting.registrations_mode + require_invite_text = Setting.require_invite_text + example.run + Setting.require_invite_text = require_invite_text + Setting.registrations_mode = registrations_mode + end + it 'redirects to setup' do subject expect(response).to redirect_to auth_setup_path diff --git a/spec/controllers/well_known/webfinger_controller_spec.rb b/spec/controllers/well_known/webfinger_controller_spec.rb index 8574d369d..1ccfb218e 100644 --- a/spec/controllers/well_known/webfinger_controller_spec.rb +++ b/spec/controllers/well_known/webfinger_controller_spec.rb @@ -4,6 +4,10 @@ describe WellKnown::WebfingerController, type: :controller do render_views describe 'GET #show' do + subject do + get :show, params: { resource: resource }, format: :json + end + let(:alternate_domains) { [] } let(:alice) { Fabricate(:account, username: 'alice') } let(:resource) { nil } @@ -15,10 +19,6 @@ describe WellKnown::WebfingerController, type: :controller do Rails.configuration.x.alternate_domains = tmp end - subject do - get :show, params: { resource: resource }, format: :json - end - shared_examples 'a successful response' do it 'returns http success' do expect(response).to have_http_status(200) diff --git a/spec/lib/activitypub/activity/accept_spec.rb b/spec/lib/activitypub/activity/accept_spec.rb index 304cf2208..95a5a8747 100644 --- a/spec/lib/activitypub/activity/accept_spec.rb +++ b/spec/lib/activitypub/activity/accept_spec.rb @@ -42,6 +42,8 @@ RSpec.describe ActivityPub::Activity::Accept do end context 'given a relay' do + subject { described_class.new(json, sender) } + let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') } let(:json) do @@ -59,8 +61,6 @@ RSpec.describe ActivityPub::Activity::Accept do }.with_indifferent_access end - subject { described_class.new(json, sender) } - it 'marks the relay as accepted' do subject.perform expect(relay.reload.accepted?).to be true diff --git a/spec/lib/activitypub/activity/announce_spec.rb b/spec/lib/activitypub/activity/announce_spec.rb index adb13acc2..b3257e881 100644 --- a/spec/lib/activitypub/activity/announce_spec.rb +++ b/spec/lib/activitypub/activity/announce_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::Activity::Announce do + subject { described_class.new(json, sender) } + let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', uri: 'https://example.com/actor') } let(:recipient) { Fabricate(:account) } let(:status) { Fabricate(:status, account: recipient) } @@ -27,8 +29,6 @@ RSpec.describe ActivityPub::Activity::Announce do } end - subject { described_class.new(json, sender) } - describe '#perform' do context 'when sender is followed by a local account' do before do @@ -110,13 +110,13 @@ RSpec.describe ActivityPub::Activity::Announce do end context 'when the sender is relayed' do + subject { described_class.new(json, sender, relayed_through_actor: relay_account) } + let!(:relay_account) { Fabricate(:account, inbox_url: 'https://relay.example.com/inbox') } let!(:relay) { Fabricate(:relay, inbox_url: 'https://relay.example.com/inbox') } let(:object_json) { 'https://example.com/actor/hello-world' } - subject { described_class.new(json, sender, relayed_through_actor: relay_account) } - before do stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: Oj.dump(unknown_object_json)) end diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index ddbdb07aa..c26c8b358 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -752,6 +752,8 @@ RSpec.describe ActivityPub::Activity::Create do end context 'with an encrypted message' do + subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) } + let(:recipient) { Fabricate(:account) } let(:object_json) do { @@ -776,8 +778,6 @@ RSpec.describe ActivityPub::Activity::Create do end let(:target_device) { Fabricate(:device, account: recipient) } - subject { described_class.new(json, sender, delivery: true, delivered_to_account_id: recipient.id) } - before do subject.perform end @@ -831,6 +831,8 @@ RSpec.describe ActivityPub::Activity::Create do end context 'when sender replies to local status' do + subject { described_class.new(json, sender, delivery: true) } + let!(:local_status) { Fabricate(:status) } let(:object_json) do { @@ -841,8 +843,6 @@ RSpec.describe ActivityPub::Activity::Create do } end - subject { described_class.new(json, sender, delivery: true) } - before do subject.perform end @@ -856,6 +856,8 @@ RSpec.describe ActivityPub::Activity::Create do end context 'when sender targets a local user' do + subject { described_class.new(json, sender, delivery: true) } + let!(:local_account) { Fabricate(:account) } let(:object_json) do { @@ -866,8 +868,6 @@ RSpec.describe ActivityPub::Activity::Create do } end - subject { described_class.new(json, sender, delivery: true) } - before do subject.perform end @@ -881,6 +881,8 @@ RSpec.describe ActivityPub::Activity::Create do end context 'when sender cc\'s a local user' do + subject { described_class.new(json, sender, delivery: true) } + let!(:local_account) { Fabricate(:account) } let(:object_json) do { @@ -891,8 +893,6 @@ RSpec.describe ActivityPub::Activity::Create do } end - subject { described_class.new(json, sender, delivery: true) } - before do subject.perform end diff --git a/spec/lib/activitypub/activity/reject_spec.rb b/spec/lib/activitypub/activity/reject_spec.rb index fed4cd8cd..7f04db4e6 100644 --- a/spec/lib/activitypub/activity/reject_spec.rb +++ b/spec/lib/activitypub/activity/reject_spec.rb @@ -121,6 +121,8 @@ RSpec.describe ActivityPub::Activity::Reject do end context 'given a relay' do + subject { described_class.new(json, sender) } + let!(:relay) { Fabricate(:relay, state: :pending, follow_activity_id: 'https://abc-123/456') } let(:json) do @@ -138,8 +140,6 @@ RSpec.describe ActivityPub::Activity::Reject do }.with_indifferent_access end - subject { described_class.new(json, sender) } - it 'marks the relay as rejected' do subject.perform expect(relay.reload.rejected?).to be true diff --git a/spec/lib/activitypub/activity/undo_spec.rb b/spec/lib/activitypub/activity/undo_spec.rb index c0309e49d..0bd1f17d3 100644 --- a/spec/lib/activitypub/activity/undo_spec.rb +++ b/spec/lib/activitypub/activity/undo_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::Activity::Undo do + subject { described_class.new(json, sender) } + let(:sender) { Fabricate(:account, domain: 'example.com') } let(:json) do @@ -13,8 +15,6 @@ RSpec.describe ActivityPub::Activity::Undo do }.with_indifferent_access end - subject { described_class.new(json, sender) } - describe '#perform' do context 'with Announce' do let(:status) { Fabricate(:status) } diff --git a/spec/lib/activitypub/activity/update_spec.rb b/spec/lib/activitypub/activity/update_spec.rb index 4cd853af2..d2a1edd7a 100644 --- a/spec/lib/activitypub/activity/update_spec.rb +++ b/spec/lib/activitypub/activity/update_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' RSpec.describe ActivityPub::Activity::Update do + subject { described_class.new(json, sender) } + let!(:sender) { Fabricate(:account) } before do sender.update!(uri: ActivityPub::TagManager.instance.uri_for(sender)) end - subject { described_class.new(json, sender) } - describe '#perform' do context 'with an Actor object' do let(:modified_sender) do diff --git a/spec/lib/activitypub/adapter_spec.rb b/spec/lib/activitypub/adapter_spec.rb index ea03797aa..e4c403abb 100644 --- a/spec/lib/activitypub/adapter_spec.rb +++ b/spec/lib/activitypub/adapter_spec.rb @@ -41,10 +41,10 @@ RSpec.describe ActivityPub::Adapter do end describe '#serializable_hash' do - let(:serializer_class) {} - subject { ActiveModelSerializers::SerializableResource.new(TestObject.new(foo: 'bar'), serializer: serializer_class, adapter: described_class).as_json } + let(:serializer_class) {} + context 'when serializer defines no context' do let(:serializer_class) { TestWithBasicContextSerializer } diff --git a/spec/lib/activitypub/dereferencer_spec.rb b/spec/lib/activitypub/dereferencer_spec.rb index e50b497c7..800473a7c 100644 --- a/spec/lib/activitypub/dereferencer_spec.rb +++ b/spec/lib/activitypub/dereferencer_spec.rb @@ -2,13 +2,13 @@ require 'rails_helper' RSpec.describe ActivityPub::Dereferencer do describe '#object' do + subject { described_class.new(uri, permitted_origin: permitted_origin, signature_actor: signature_actor).object } + let(:object) { { '@context': 'https://www.w3.org/ns/activitystreams', id: 'https://example.com/foo', type: 'Note', content: 'Hoge' } } let(:permitted_origin) { 'https://example.com' } let(:signature_actor) { nil } let(:uri) { nil } - subject { described_class.new(uri, permitted_origin: permitted_origin, signature_actor: signature_actor).object } - before do stub_request(:get, 'https://example.com/foo').to_return(body: Oj.dump(object), headers: { 'Content-Type' => 'application/activity+json' }) end diff --git a/spec/lib/activitypub/linked_data_signature_spec.rb b/spec/lib/activitypub/linked_data_signature_spec.rb index d55a7c7fa..ecb1e16db 100644 --- a/spec/lib/activitypub/linked_data_signature_spec.rb +++ b/spec/lib/activitypub/linked_data_signature_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe ActivityPub::LinkedDataSignature do include JsonLdHelper + subject { described_class.new(json) } + let!(:sender) { Fabricate(:account, uri: 'http://example.com/alice') } let(:raw_json) do @@ -14,8 +16,6 @@ RSpec.describe ActivityPub::LinkedDataSignature do let(:json) { raw_json.merge('signature' => signature) } - subject { described_class.new(json) } - before do stub_jsonld_contexts! end diff --git a/spec/lib/link_details_extractor_spec.rb b/spec/lib/link_details_extractor_spec.rb index 7eb15ced3..fcc265474 100644 --- a/spec/lib/link_details_extractor_spec.rb +++ b/spec/lib/link_details_extractor_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe LinkDetailsExtractor do + subject { described_class.new(original_url, html, html_charset) } + let(:original_url) { '' } let(:html) { '' } let(:html_charset) { nil } - subject { described_class.new(original_url, html, html_charset) } - describe '#canonical_url' do let(:original_url) { 'https://foo.com/article?bar=baz123' } diff --git a/spec/lib/status_filter_spec.rb b/spec/lib/status_filter_spec.rb index cdb482059..08519bc59 100644 --- a/spec/lib/status_filter_spec.rb +++ b/spec/lib/status_filter_spec.rb @@ -31,10 +31,10 @@ describe StatusFilter do end context 'with real account' do - let(:account) { Fabricate(:account) } - subject { described_class.new(status, account) } + let(:account) { Fabricate(:account) } + context 'when there are no connections' do it { is_expected.to_not be_filtered } end diff --git a/spec/lib/status_reach_finder_spec.rb b/spec/lib/status_reach_finder_spec.rb index f0c22b165..785ce28a0 100644 --- a/spec/lib/status_reach_finder_spec.rb +++ b/spec/lib/status_reach_finder_spec.rb @@ -5,13 +5,13 @@ require 'rails_helper' describe StatusReachFinder do describe '#inboxes' do context 'for a local status' do + subject { described_class.new(status) } + let(:parent_status) { nil } let(:visibility) { :public } let(:alice) { Fabricate(:account, username: 'alice') } let(:status) { Fabricate(:status, account: alice, thread: parent_status, visibility: visibility) } - subject { described_class.new(status) } - context 'when it contains mentions of remote accounts' do let(:bob) { Fabricate(:account, username: 'bob', domain: 'foo.bar', protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') } diff --git a/spec/lib/suspicious_sign_in_detector_spec.rb b/spec/lib/suspicious_sign_in_detector_spec.rb index 101a18aa0..05aadfd8f 100644 --- a/spec/lib/suspicious_sign_in_detector_spec.rb +++ b/spec/lib/suspicious_sign_in_detector_spec.rb @@ -2,12 +2,12 @@ require 'rails_helper' RSpec.describe SuspiciousSignInDetector do describe '#suspicious?' do + subject { described_class.new(user).suspicious?(request) } + let(:user) { Fabricate(:user, current_sign_in_at: 1.day.ago) } let(:request) { double(remote_ip: remote_ip) } let(:remote_ip) { nil } - subject { described_class.new(user).suspicious?(request) } - context 'when user has 2FA enabled' do before do user.update!(otp_required_for_login: true) diff --git a/spec/lib/text_formatter_spec.rb b/spec/lib/text_formatter_spec.rb index 63a9075c7..04ae4e02c 100644 --- a/spec/lib/text_formatter_spec.rb +++ b/spec/lib/text_formatter_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe TextFormatter do describe '#to_s' do - let(:preloaded_accounts) { nil } - subject { described_class.new(text, preloaded_accounts: preloaded_accounts).to_s } + let(:preloaded_accounts) { nil } + context 'given text containing plain text' do let(:text) { 'text' } diff --git a/spec/lib/vacuum/backups_vacuum_spec.rb b/spec/lib/vacuum/backups_vacuum_spec.rb index 4e2de083f..c505a3e1a 100644 --- a/spec/lib/vacuum/backups_vacuum_spec.rb +++ b/spec/lib/vacuum/backups_vacuum_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe Vacuum::BackupsVacuum do - let(:retention_period) { 7.days } - subject { described_class.new(retention_period) } + let(:retention_period) { 7.days } + describe '#perform' do let!(:expired_backup) { Fabricate(:backup, created_at: (retention_period + 1.day).ago) } let!(:current_backup) { Fabricate(:backup) } diff --git a/spec/lib/vacuum/media_attachments_vacuum_spec.rb b/spec/lib/vacuum/media_attachments_vacuum_spec.rb index 436237b25..afcb6f878 100644 --- a/spec/lib/vacuum/media_attachments_vacuum_spec.rb +++ b/spec/lib/vacuum/media_attachments_vacuum_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe Vacuum::MediaAttachmentsVacuum do + subject { described_class.new(retention_period) } + let(:retention_period) { 7.days } let(:remote_status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com')) } let(:local_status) { Fabricate(:status) } - subject { described_class.new(retention_period) } - describe '#perform' do let!(:old_remote_media) { Fabricate(:media_attachment, remote_url: 'https://example.com/foo.png', status: remote_status, created_at: (retention_period + 1.day).ago, updated_at: (retention_period + 1.day).ago) } let!(:old_local_media) { Fabricate(:media_attachment, status: local_status, created_at: (retention_period + 1.day).ago, updated_at: (retention_period + 1.day).ago) } diff --git a/spec/lib/vacuum/preview_cards_vacuum_spec.rb b/spec/lib/vacuum/preview_cards_vacuum_spec.rb index 275f9ba92..524f4c927 100644 --- a/spec/lib/vacuum/preview_cards_vacuum_spec.rb +++ b/spec/lib/vacuum/preview_cards_vacuum_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe Vacuum::PreviewCardsVacuum do - let(:retention_period) { 7.days } - subject { described_class.new(retention_period) } + let(:retention_period) { 7.days } + describe '#perform' do let!(:orphaned_preview_card) { Fabricate(:preview_card, created_at: 2.days.ago) } let!(:old_preview_card) { Fabricate(:preview_card, updated_at: (retention_period + 1.day).ago) } diff --git a/spec/lib/vacuum/statuses_vacuum_spec.rb b/spec/lib/vacuum/statuses_vacuum_spec.rb index 83f3c5c9f..9583376b7 100644 --- a/spec/lib/vacuum/statuses_vacuum_spec.rb +++ b/spec/lib/vacuum/statuses_vacuum_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe Vacuum::StatusesVacuum do + subject { described_class.new(retention_period) } + let(:retention_period) { 7.days } let(:remote_account) { Fabricate(:account, domain: 'example.com') } - subject { described_class.new(retention_period) } - describe '#perform' do let!(:remote_status_old) { Fabricate(:status, account: remote_account, created_at: (retention_period + 2.days).ago) } let!(:remote_status_recent) { Fabricate(:status, account: remote_account, created_at: (retention_period - 2.days).ago) } diff --git a/spec/models/account/field_spec.rb b/spec/models/account/field_spec.rb index 40bbee025..36e1a8595 100644 --- a/spec/models/account/field_spec.rb +++ b/spec/models/account/field_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe Account::Field, type: :model do describe '#verified?' do - let(:account) { double('Account', local?: true) } - subject { described_class.new(account, 'name' => 'Foo', 'value' => 'Bar', 'verified_at' => verified_at) } + let(:account) { double('Account', local?: true) } + context 'when verified_at is set' do let(:verified_at) { Time.now.utc.iso8601 } @@ -24,11 +24,11 @@ RSpec.describe Account::Field, type: :model do end describe '#mark_verified!' do + subject { described_class.new(account, original_hash) } + let(:account) { double('Account', local?: true) } let(:original_hash) { { 'name' => 'Foo', 'value' => 'Bar' } } - subject { described_class.new(account, original_hash) } - before do subject.mark_verified! end @@ -43,10 +43,10 @@ RSpec.describe Account::Field, type: :model do end describe '#verifiable?' do - let(:account) { double('Account', local?: local) } - subject { described_class.new(account, 'name' => 'Foo', 'value' => value) } + let(:account) { double('Account', local?: local) } + context 'for local accounts' do let(:local) { true } diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 03ed12d78..726e33048 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe Account, type: :model do context do - let(:bob) { Fabricate(:account, username: 'bob') } - subject { Fabricate(:account) } + let(:bob) { Fabricate(:account, username: 'bob') } + describe '#suspend!' do it 'marks the account as suspended' do subject.suspend! @@ -87,14 +87,14 @@ RSpec.describe Account, type: :model do end describe 'Local domain user methods' do + subject { Fabricate(:account, domain: nil, username: 'alice') } + around do |example| before = Rails.configuration.x.local_domain example.run Rails.configuration.x.local_domain = before end - subject { Fabricate(:account, domain: nil, username: 'alice') } - describe '#to_webfinger_s' do it 'returns a webfinger string for the account' do Rails.configuration.x.local_domain = 'example.com' @@ -243,13 +243,13 @@ RSpec.describe Account, type: :model do end describe '#favourited?' do + subject { Fabricate(:account) } + let(:original_status) do author = Fabricate(:account, username: 'original') Fabricate(:status, account: author) end - subject { Fabricate(:account) } - context 'when the status is a reblog of another status' do let(:original_reblog) do author = Fabricate(:account, username: 'original_reblogger') @@ -281,13 +281,13 @@ RSpec.describe Account, type: :model do end describe '#reblogged?' do + subject { Fabricate(:account) } + let(:original_status) do author = Fabricate(:account, username: 'original') Fabricate(:status, account: author) end - subject { Fabricate(:account) } - context 'when the status is a reblog of another status' do let(:original_reblog) do author = Fabricate(:account, username: 'original_reblogger') diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index d3c011b3a..8bd86730b 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -132,11 +132,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#invalidate_last_inspected' do + subject { account_statuses_cleanup_policy.invalidate_last_inspected(status, action) } + let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) } let(:status) { Fabricate(:status, id: 10, account: account) } - subject { account_statuses_cleanup_policy.invalidate_last_inspected(status, action) } - before do account_statuses_cleanup_policy.record_last_inspected(42) end @@ -231,11 +231,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#compute_cutoff_id' do + subject { account_statuses_cleanup_policy.compute_cutoff_id } + let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) } let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) } - subject { account_statuses_cleanup_policy.compute_cutoff_id } - context 'when the account has posted multiple toots' do let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) } let!(:old_status) { Fabricate(:status, created_at: 3.weeks.ago, account: account) } @@ -254,6 +254,8 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#statuses_to_delete' do + subject { account_statuses_cleanup_policy.statuses_to_delete } + let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) } let!(:very_old_status) { Fabricate(:status, created_at: 3.years.ago, account: account) } let!(:pinned_status) { Fabricate(:status, created_at: 1.year.ago, account: account) } @@ -275,8 +277,6 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) } - subject { account_statuses_cleanup_policy.statuses_to_delete } - before do 4.times { faved4.increment_count!(:favourites_count) } 5.times { faved5.increment_count!(:favourites_count) } @@ -285,11 +285,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end context 'when passed a max_id' do + subject { account_statuses_cleanup_policy.statuses_to_delete(50, old_status.id).pluck(:id) } + let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) } - subject { account_statuses_cleanup_policy.statuses_to_delete(50, old_status.id).pluck(:id) } - it 'returns statuses including max_id' do expect(subject).to include(old_status.id) end @@ -304,11 +304,11 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end context 'when passed a min_id' do + subject { account_statuses_cleanup_policy.statuses_to_delete(50, recent_status.id, old_status.id).pluck(:id) } + let!(:old_status) { Fabricate(:status, created_at: 1.year.ago, account: account) } let!(:slightly_less_old_status) { Fabricate(:status, created_at: 6.months.ago, account: account) } - subject { account_statuses_cleanup_policy.statuses_to_delete(50, recent_status.id, old_status.id).pluck(:id) } - it 'returns statuses including min_id' do expect(subject).to include(old_status.id) end diff --git a/spec/models/account_statuses_filter_spec.rb b/spec/models/account_statuses_filter_spec.rb index 03f0ffeb0..fa7664d92 100644 --- a/spec/models/account_statuses_filter_spec.rb +++ b/spec/models/account_statuses_filter_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' RSpec.describe AccountStatusesFilter do + subject { described_class.new(account, current_account, params) } + let(:account) { Fabricate(:account) } let(:current_account) { nil } let(:params) { {} } - subject { described_class.new(account, current_account, params) } - def status!(visibility) Fabricate(:status, account: account, visibility: visibility) end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index fbfc9fbbc..ed3fc056b 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -225,10 +225,10 @@ describe AccountInteractions do end describe '#mute_conversation!' do - let(:conversation) { Fabricate(:conversation) } - subject { account.mute_conversation!(conversation) } + let(:conversation) { Fabricate(:conversation) } + it 'creates and returns ConversationMute' do expect do expect(subject).to be_a ConversationMute @@ -237,10 +237,10 @@ describe AccountInteractions do end describe '#block_domain!' do - let(:domain) { 'example.com' } - subject { account.block_domain!(domain) } + let(:domain) { 'example.com' } + it 'creates and returns AccountDomainBlock' do expect do expect(subject).to be_a AccountDomainBlock @@ -303,10 +303,10 @@ describe AccountInteractions do end describe '#unmute_conversation!' do - let(:conversation) { Fabricate(:conversation) } - subject { account.unmute_conversation!(conversation) } + let(:conversation) { Fabricate(:conversation) } + context 'muting the conversation' do it 'returns destroyed ConversationMute' do account.conversation_mutes.create(conversation: conversation) @@ -323,10 +323,10 @@ describe AccountInteractions do end describe '#unblock_domain!' do - let(:domain) { 'example.com' } - subject { account.unblock_domain!(domain) } + let(:domain) { 'example.com' } + context 'blocking the domain' do it 'returns destroyed AccountDomainBlock' do account_domain_block = Fabricate(:account_domain_block, domain: domain) @@ -395,10 +395,10 @@ describe AccountInteractions do end describe '#domain_blocking?' do - let(:domain) { 'example.com' } - subject { account.domain_blocking?(domain) } + let(:domain) { 'example.com' } + context 'blocking the domain' do it 'returns true' do account_domain_block = Fabricate(:account_domain_block, domain: domain) @@ -433,10 +433,10 @@ describe AccountInteractions do end describe '#muting_conversation?' do - let(:conversation) { Fabricate(:conversation) } - subject { account.muting_conversation?(conversation) } + let(:conversation) { Fabricate(:conversation) } + context 'muting the conversation' do it 'returns true' do account.conversation_mutes.create(conversation: conversation) @@ -452,13 +452,13 @@ describe AccountInteractions do end describe '#muting_notifications?' do + subject { account.muting_notifications?(target_account) } + before do mute = Fabricate(:mute, target_account: target_account, account: account, hide_notifications: hide) account.mute_relationships << mute end - subject { account.muting_notifications?(target_account) } - context 'muting notifications of target_account' do let(:hide) { true } @@ -494,10 +494,10 @@ describe AccountInteractions do end describe '#favourited?' do - let(:status) { Fabricate(:status, account: account, favourites: favourites) } - subject { account.favourited?(status) } + let(:status) { Fabricate(:status, account: account, favourites: favourites) } + context 'favorited' do let(:favourites) { [Fabricate(:favourite, account: account)] } @@ -516,10 +516,10 @@ describe AccountInteractions do end describe '#reblogged?' do - let(:status) { Fabricate(:status, account: account, reblogs: reblogs) } - subject { account.reblogged?(status) } + let(:status) { Fabricate(:status, account: account, reblogs: reblogs) } + context 'reblogged' do let(:reblogs) { [Fabricate(:status, account: account)] } @@ -538,10 +538,10 @@ describe AccountInteractions do end describe '#pinned?' do - let(:status) { Fabricate(:status, account: account) } - subject { account.pinned?(status) } + let(:status) { Fabricate(:status, account: account) } + context 'pinned' do it 'returns true' do Fabricate(:status_pin, account: account, status: status) diff --git a/spec/models/custom_emoji_filter_spec.rb b/spec/models/custom_emoji_filter_spec.rb index 515c0a715..30f0ec2b2 100644 --- a/spec/models/custom_emoji_filter_spec.rb +++ b/spec/models/custom_emoji_filter_spec.rb @@ -4,12 +4,12 @@ require 'rails_helper' RSpec.describe CustomEmojiFilter do describe '#results' do + subject { described_class.new(params).results } + let!(:custom_emoji_0) { Fabricate(:custom_emoji, domain: 'a') } let!(:custom_emoji_1) { Fabricate(:custom_emoji, domain: 'b') } let!(:custom_emoji_2) { Fabricate(:custom_emoji, domain: nil, shortcode: 'hoge') } - subject { described_class.new(params).results } - context 'params have values' do context 'local' do let(:params) { { local: true } } diff --git a/spec/models/custom_emoji_spec.rb b/spec/models/custom_emoji_spec.rb index 1fc112db3..f6fcd468b 100644 --- a/spec/models/custom_emoji_spec.rb +++ b/spec/models/custom_emoji_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe CustomEmoji, type: :model do describe '#search' do - let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) } - subject { described_class.search(search_term) } + let(:custom_emoji) { Fabricate(:custom_emoji, shortcode: shortcode) } + context 'shortcode is exact' do let(:shortcode) { 'blobpats' } let(:search_term) { 'blobpats' } @@ -26,10 +26,10 @@ RSpec.describe CustomEmoji, type: :model do end describe '#local?' do - let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) } - subject { custom_emoji.local? } + let(:custom_emoji) { Fabricate(:custom_emoji, domain: domain) } + context 'domain is nil' do let(:domain) { nil } @@ -55,10 +55,10 @@ RSpec.describe CustomEmoji, type: :model do end describe '.from_text' do - let!(:emojo) { Fabricate(:custom_emoji) } - subject { described_class.from_text(text, nil) } + let!(:emojo) { Fabricate(:custom_emoji) } + context 'with plain text' do let(:text) { 'Hello :coolcat:' } diff --git a/spec/models/home_feed_spec.rb b/spec/models/home_feed_spec.rb index 80f6edbff..196bef1e4 100644 --- a/spec/models/home_feed_spec.rb +++ b/spec/models/home_feed_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe HomeFeed, type: :model do - let(:account) { Fabricate(:account) } - subject { described_class.new(account) } + let(:account) { Fabricate(:account) } + describe '#get' do before do Fabricate(:status, account: account, id: 1) diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index 8889d5f7c..57e131423 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe MediaAttachment, type: :model do describe 'local?' do - let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) } - subject { media_attachment.local? } + let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url) } + context 'remote_url is blank' do let(:remote_url) { '' } @@ -24,10 +24,10 @@ RSpec.describe MediaAttachment, type: :model do end describe 'needs_redownload?' do - let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) } - subject { media_attachment.needs_redownload? } + let(:media_attachment) { Fabricate(:media_attachment, remote_url: remote_url, file: file) } + context 'file is blank' do let(:file) { nil } diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb index be46639c5..59c81dd95 100644 --- a/spec/models/public_feed_spec.rb +++ b/spec/models/public_feed_spec.rb @@ -40,6 +40,8 @@ RSpec.describe PublicFeed, type: :model do end context 'without local_only option' do + subject { described_class.new(viewer).get(20).map(&:id) } + let(:viewer) { nil } let!(:local_account) { Fabricate(:account, domain: nil) } @@ -47,8 +49,6 @@ RSpec.describe PublicFeed, type: :model do let!(:local_status) { Fabricate(:status, account: local_account) } let!(:remote_status) { Fabricate(:status, account: remote_account) } - subject { described_class.new(viewer).get(20).map(&:id) } - context 'without a viewer' do let(:viewer) { nil } @@ -75,13 +75,13 @@ RSpec.describe PublicFeed, type: :model do end context 'with a local_only option set' do + subject { described_class.new(viewer, local: true).get(20).map(&:id) } + let!(:local_account) { Fabricate(:account, domain: nil) } let!(:remote_account) { Fabricate(:account, domain: 'test.com') } let!(:local_status) { Fabricate(:status, account: local_account) } let!(:remote_status) { Fabricate(:status, account: remote_account) } - subject { described_class.new(viewer, local: true).get(20).map(&:id) } - context 'without a viewer' do let(:viewer) { nil } @@ -108,13 +108,13 @@ RSpec.describe PublicFeed, type: :model do end context 'with a remote_only option set' do + subject { described_class.new(viewer, remote: true).get(20).map(&:id) } + let!(:local_account) { Fabricate(:account, domain: nil) } let!(:remote_account) { Fabricate(:account, domain: 'test.com') } let!(:local_status) { Fabricate(:status, account: local_account) } let!(:remote_status) { Fabricate(:status, account: remote_account) } - subject { described_class.new(viewer, remote: true).get(20).map(&:id) } - context 'without a viewer' do let(:viewer) { nil } @@ -135,12 +135,12 @@ RSpec.describe PublicFeed, type: :model do end describe 'with an account passed in' do + subject { described_class.new(@account).get(20).map(&:id) } + before do @account = Fabricate(:account) end - subject { described_class.new(@account).get(20).map(&:id) } - it 'excludes statuses from accounts blocked by the account' do blocked = Fabricate(:account) @account.block!(blocked) diff --git a/spec/models/remote_follow_spec.rb b/spec/models/remote_follow_spec.rb index c6bbecf25..ea36b0076 100644 --- a/spec/models/remote_follow_spec.rb +++ b/spec/models/remote_follow_spec.rb @@ -51,6 +51,8 @@ RSpec.describe RemoteFollow do end describe '#subscribe_address_for' do + subject { remote_follow.subscribe_address_for(account) } + before do remote_follow.valid? end @@ -58,8 +60,6 @@ RSpec.describe RemoteFollow do let(:attrs) { { acct: 'gargron@quitter.no' } } let(:account) { Fabricate(:account, username: 'alice') } - subject { remote_follow.subscribe_address_for(account) } - it 'returns subscribe address' do expect(subject).to eq 'https://quitter.no/main/ostatussub?profile=https%3A%2F%2Fcb6e6126.ngrok.io%2Fusers%2Falice' end diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index 86fdf4e08..826a13878 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -163,12 +163,12 @@ RSpec.describe Setting, type: :model do end describe '.default_settings' do + subject { described_class.default_settings } + before do allow(RailsSettings::Default).to receive(:enabled?).and_return(enabled) end - subject { described_class.default_settings } - context 'RailsSettings::Default.enabled? is false' do let(:enabled) { false } diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 78cc05959..442f14ddf 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe Status, type: :model do + subject { Fabricate(:status, account: alice) } + let(:alice) { Fabricate(:account, username: 'alice') } let(:bob) { Fabricate(:account, username: 'bob') } let(:other) { Fabricate(:status, account: bob, text: 'Skulls for the skull god! The enemy\'s gates are sideways!') } - subject { Fabricate(:status, account: alice) } - describe '#local?' do it 'returns true when no remote URI is set' do expect(subject.local?).to be true @@ -204,11 +204,11 @@ RSpec.describe Status, type: :model do end describe '.mutes_map' do + subject { Status.mutes_map([status.conversation.id], account) } + let(:status) { Fabricate(:status) } let(:account) { Fabricate(:account) } - subject { Status.mutes_map([status.conversation.id], account) } - it 'returns a hash' do expect(subject).to be_a Hash end @@ -220,11 +220,11 @@ RSpec.describe Status, type: :model do end describe '.favourites_map' do + subject { Status.favourites_map([status], account) } + let(:status) { Fabricate(:status) } let(:account) { Fabricate(:account) } - subject { Status.favourites_map([status], account) } - it 'returns a hash' do expect(subject).to be_a Hash end @@ -236,11 +236,11 @@ RSpec.describe Status, type: :model do end describe '.reblogs_map' do + subject { Status.reblogs_map([status], account) } + let(:status) { Fabricate(:status) } let(:account) { Fabricate(:account) } - subject { Status.reblogs_map([status], account) } - it 'returns a hash' do expect(subject).to be_a Hash end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index d23439f1a..9af616b32 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -142,10 +142,10 @@ RSpec.describe User, type: :model do end describe '#confirm' do - let(:new_email) { 'new-email@example.com' } - subject { user.confirm } + let(:new_email) { 'new-email@example.com' } + before do allow(TriggerWebhookWorker).to receive(:perform_async) end diff --git a/spec/models/web/push_subscription_spec.rb b/spec/models/web/push_subscription_spec.rb index eeadbb71c..388154000 100644 --- a/spec/models/web/push_subscription_spec.rb +++ b/spec/models/web/push_subscription_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe Web::PushSubscription, type: :model do + subject { described_class.new(data: data) } + let(:account) { Fabricate(:account) } let(:policy) { 'all' } @@ -19,8 +21,6 @@ RSpec.describe Web::PushSubscription, type: :model do } end - subject { described_class.new(data: data) } - describe '#pushable?' do let(:notification_type) { :mention } let(:notification) { Fabricate(:notification, account: account, type: notification_type) } diff --git a/spec/presenters/familiar_followers_presenter_spec.rb b/spec/presenters/familiar_followers_presenter_spec.rb index 17be4b971..607e3002f 100644 --- a/spec/presenters/familiar_followers_presenter_spec.rb +++ b/spec/presenters/familiar_followers_presenter_spec.rb @@ -4,12 +4,12 @@ require 'rails_helper' RSpec.describe FamiliarFollowersPresenter do describe '#accounts' do + subject { described_class.new(requested_accounts, account.id) } + let(:account) { Fabricate(:account) } let(:familiar_follower) { Fabricate(:account) } let(:requested_accounts) { Fabricate.times(2, :account) } - subject { described_class.new(requested_accounts, account.id) } - before do familiar_follower.follow!(requested_accounts.first) account.follow!(familiar_follower) diff --git a/spec/serializers/activitypub/note_spec.rb b/spec/serializers/activitypub/note_spec.rb index 55bfbc16b..7ea47baef 100644 --- a/spec/serializers/activitypub/note_spec.rb +++ b/spec/serializers/activitypub/note_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' describe ActivityPub::NoteSerializer do + subject { JSON.parse(@serialization.to_json) } + let!(:account) { Fabricate(:account) } let!(:other) { Fabricate(:account) } let!(:parent) { Fabricate(:status, account: account, visibility: :public) } @@ -16,8 +18,6 @@ describe ActivityPub::NoteSerializer do @serialization = ActiveModelSerializers::SerializableResource.new(parent, serializer: ActivityPub::NoteSerializer, adapter: ActivityPub::Adapter) end - subject { JSON.parse(@serialization.to_json) } - it 'has a Note type' do expect(subject['type']).to eql('Note') end diff --git a/spec/serializers/activitypub/update_poll_spec.rb b/spec/serializers/activitypub/update_poll_spec.rb index f9e035eab..4360808b5 100644 --- a/spec/serializers/activitypub/update_poll_spec.rb +++ b/spec/serializers/activitypub/update_poll_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' describe ActivityPub::UpdatePollSerializer do + subject { JSON.parse(@serialization.to_json) } + let(:account) { Fabricate(:account) } let(:poll) { Fabricate(:poll, account: account) } let!(:status) { Fabricate(:status, account: account, poll: poll) } @@ -11,8 +13,6 @@ describe ActivityPub::UpdatePollSerializer do @serialization = ActiveModelSerializers::SerializableResource.new(status, serializer: ActivityPub::UpdatePollSerializer, adapter: ActivityPub::Adapter) end - subject { JSON.parse(@serialization.to_json) } - it 'has a Update type' do expect(subject['type']).to eql('Update') end diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index 3bca06b73..528639943 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -3,12 +3,12 @@ require 'rails_helper' describe REST::AccountSerializer do + subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) } + let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } let(:user) { Fabricate(:user, role: role) } let(:account) { user.account } - subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) } - context 'when the account is suspended' do before do account.suspend! diff --git a/spec/services/activitypub/fetch_featured_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_collection_service_spec.rb index 23d90a9a2..d9266ffc2 100644 --- a/spec/services/activitypub/fetch_featured_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_collection_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do + subject { described_class.new } + let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/account', featured_collection_url: 'https://example.com/account/pinned') } let!(:known_status) { Fabricate(:status, account: actor, uri: 'https://example.com/account/pinned/1') } @@ -56,8 +58,6 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do }.with_indifferent_access end - subject { described_class.new } - shared_examples 'sets pinned posts' do before do stub_request(:get, 'https://example.com/account/pinned/1').to_return(status: 200, body: Oj.dump(status_json_1)) diff --git a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb index 692866bce..2110baa2d 100644 --- a/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb +++ b/spec/services/activitypub/fetch_featured_tags_collection_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service do + subject { described_class.new } + let(:collection_url) { 'https://example.com/account/tags' } let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/account') } @@ -21,8 +23,6 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service d }.with_indifferent_access end - subject { described_class.new } - shared_examples 'sets featured tags' do before do subject.call(actor, collection_url) diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index 4f3503ac2..6e47392b3 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do include ActionView::Helpers::TextHelper + subject { described_class.new } + let!(:sender) { Fabricate(:account, domain: 'foo.bar', uri: 'https://foo.bar') } let!(:recipient) { Fabricate(:account) } @@ -18,8 +20,6 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do } end - subject { described_class.new } - before do stub_request(:get, 'https://foo.bar/watch?v=12345').to_return(status: 404, body: '') stub_request(:get, object[:id]).to_return(body: Oj.dump(object)) diff --git a/spec/services/activitypub/fetch_replies_service_spec.rb b/spec/services/activitypub/fetch_replies_service_spec.rb index 5741e0c3f..0231a5e9a 100644 --- a/spec/services/activitypub/fetch_replies_service_spec.rb +++ b/spec/services/activitypub/fetch_replies_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::FetchRepliesService, type: :service do + subject { described_class.new } + let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') } let(:status) { Fabricate(:status, account: actor) } let(:collection_uri) { 'http://example.com/replies/1' } @@ -28,8 +30,6 @@ RSpec.describe ActivityPub::FetchRepliesService, type: :service do }.with_indifferent_access end - subject { described_class.new } - describe '#call' do context 'when the payload is a Collection with inlined replies' do context 'when passing the collection itself' do diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index d0af7de76..6c3236bae 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -31,6 +31,8 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do end context 'when account is not suspended' do + subject { described_class.new.call('alice', 'example.com', payload) } + let!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com') } let(:payload) do @@ -46,8 +48,6 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do allow(Admin::SuspensionWorker).to receive(:perform_async) end - subject { described_class.new.call('alice', 'example.com', payload) } - it 'suspends account remotely' do expect(subject.suspended?).to be true expect(subject.suspension_origin_remote?).to be true @@ -60,6 +60,8 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do end context 'when account is suspended' do + subject { described_class.new.call('alice', 'example.com', payload) } + let!(:account) { Fabricate(:account, username: 'alice', domain: 'example.com', display_name: '') } let(:payload) do @@ -78,8 +80,6 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do account.suspend!(origin: suspension_origin) end - subject { described_class.new.call('alice', 'example.com', payload) } - context 'locally' do let(:suspension_origin) { :local } diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index d35d9596d..c7d0bb92a 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::ProcessCollectionService, type: :service do + subject { described_class.new } + let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') } let(:payload) do @@ -19,8 +21,6 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do let(:json) { Oj.dump(payload) } - subject { described_class.new } - describe '#call' do context 'when actor is suspended' do before do diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 9a6d75ec0..3d6f76163 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -5,6 +5,8 @@ def poll_option_json(name, votes) end RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do + subject { described_class.new } + let!(:status) { Fabricate(:status, text: 'Hello world', account: Fabricate(:account, domain: 'example.com')) } let(:payload) do { @@ -35,8 +37,6 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do media_attachments.each { |m| status.media_attachments << m } end - subject { described_class.new } - describe '#call' do it 'updates text' do subject.call(status, json) diff --git a/spec/services/activitypub/synchronize_followers_service_spec.rb b/spec/services/activitypub/synchronize_followers_service_spec.rb index 5a37f0733..0e829a302 100644 --- a/spec/services/activitypub/synchronize_followers_service_spec.rb +++ b/spec/services/activitypub/synchronize_followers_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do + subject { described_class.new } + let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account', inbox_url: 'http://example.com/inbox') } let(:alice) { Fabricate(:account, username: 'alice') } let(:bob) { Fabricate(:account, username: 'bob') } @@ -25,8 +27,6 @@ RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do }.with_indifferent_access end - subject { described_class.new } - shared_examples 'synchronizes followers' do before do alice.follow!(actor) diff --git a/spec/services/after_block_domain_from_account_service_spec.rb b/spec/services/after_block_domain_from_account_service_spec.rb index 006e3f4d2..9cca82bff 100644 --- a/spec/services/after_block_domain_from_account_service_spec.rb +++ b/spec/services/after_block_domain_from_account_service_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' RSpec.describe AfterBlockDomainFromAccountService, type: :service do + subject { AfterBlockDomainFromAccountService.new } + let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) } let!(:alice) { Fabricate(:account, username: 'alice') } - subject { AfterBlockDomainFromAccountService.new } - before do stub_jsonld_contexts! allow(ActivityPub::DeliveryWorker).to receive(:perform_async) diff --git a/spec/services/app_sign_up_service_spec.rb b/spec/services/app_sign_up_service_spec.rb index 8ec4d4a7a..10da07dcf 100644 --- a/spec/services/app_sign_up_service_spec.rb +++ b/spec/services/app_sign_up_service_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' RSpec.describe AppSignUpService, type: :service do + subject { described_class.new } + let(:app) { Fabricate(:application, scopes: 'read write') } let(:good_params) { { username: 'alice', password: '12345678', email: 'good@email.com', agreement: true } } let(:remote_ip) { IPAddr.new('198.0.2.1') } - subject { described_class.new } - describe '#call' do it 'returns nil when registrations are closed' do tmp = Setting.registrations_mode diff --git a/spec/services/authorize_follow_service_spec.rb b/spec/services/authorize_follow_service_spec.rb index 888d694b6..8f8e44ec7 100644 --- a/spec/services/authorize_follow_service_spec.rb +++ b/spec/services/authorize_follow_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe AuthorizeFollowService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { AuthorizeFollowService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account, username: 'bob') } diff --git a/spec/services/block_domain_service_spec.rb b/spec/services/block_domain_service_spec.rb index e24e48d41..56b3a5ad1 100644 --- a/spec/services/block_domain_service_spec.rb +++ b/spec/services/block_domain_service_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' RSpec.describe BlockDomainService, type: :service do + subject { BlockDomainService.new } + let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') } let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') } let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') } let!(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status2, file: attachment_fixture('attachment.jpg')) } let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) } - subject { BlockDomainService.new } - describe 'for a suspension' do before do subject.call(DomainBlock.create!(domain: 'evil.org', severity: :suspend)) diff --git a/spec/services/block_service_spec.rb b/spec/services/block_service_spec.rb index a53e1f928..049644dbc 100644 --- a/spec/services/block_service_spec.rb +++ b/spec/services/block_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe BlockService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { BlockService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account, username: 'bob') } diff --git a/spec/services/clear_domain_media_service_spec.rb b/spec/services/clear_domain_media_service_spec.rb index e90faf84d..993ba789e 100644 --- a/spec/services/clear_domain_media_service_spec.rb +++ b/spec/services/clear_domain_media_service_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' RSpec.describe ClearDomainMediaService, type: :service do + subject { ClearDomainMediaService.new } + let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') } let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') } let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') } let!(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status2, file: attachment_fixture('attachment.jpg')) } - subject { ClearDomainMediaService.new } - describe 'for a silence with reject media' do before do subject.call(DomainBlock.create!(domain: 'evil.org', severity: :silence, reject_media: true)) diff --git a/spec/services/delete_account_service_spec.rb b/spec/services/delete_account_service_spec.rb index cc4b168fc..d0cc8d288 100644 --- a/spec/services/delete_account_service_spec.rb +++ b/spec/services/delete_account_service_spec.rb @@ -2,6 +2,8 @@ require 'rails_helper' RSpec.describe DeleteAccountService, type: :service do shared_examples 'common behavior' do + subject { described_class.new.call(account) } + let!(:status) { Fabricate(:status, account: account) } let!(:mention) { Fabricate(:mention, account: local_follower) } let!(:status_with_mention) { Fabricate(:status, account: account, mentions: [mention]) } @@ -23,8 +25,6 @@ RSpec.describe DeleteAccountService, type: :service do let!(:account_note) { Fabricate(:account_note, account: account) } - subject { described_class.new.call(account) } - it 'deletes associated owned records' do expect { subject }.to change { [ diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index 3c294cf95..d09750dd2 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe FanOutOnWriteService, type: :service do + subject { described_class.new } + let(:last_active_at) { Time.now.utc } let(:status) { Fabricate(:status, account: alice, visibility: visibility, text: 'Hello @bob #hoge') } @@ -8,8 +10,6 @@ RSpec.describe FanOutOnWriteService, type: :service do let!(:bob) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { username: 'bob' }).account } let!(:tom) { Fabricate(:user, current_sign_in_at: last_active_at).account } - subject { described_class.new } - before do bob.follow!(alice) tom.follow!(alice) diff --git a/spec/services/favourite_service_spec.rb b/spec/services/favourite_service_spec.rb index 8703c2af8..4f621200a 100644 --- a/spec/services/favourite_service_spec.rb +++ b/spec/services/favourite_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe FavouriteService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { FavouriteService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account) } let(:status) { Fabricate(:status, account: bob) } diff --git a/spec/services/fetch_resource_service_spec.rb b/spec/services/fetch_resource_service_spec.rb index c39f52632..84c4035cb 100644 --- a/spec/services/fetch_resource_service_spec.rb +++ b/spec/services/fetch_resource_service_spec.rb @@ -2,10 +2,10 @@ require 'rails_helper' RSpec.describe FetchResourceService, type: :service do describe '#call' do - let(:url) { 'http://example.com' } - subject { described_class.new.call(url) } + let(:url) { 'http://example.com' } + context 'with blank url' do let(:url) { '' } diff --git a/spec/services/follow_service_spec.rb b/spec/services/follow_service_spec.rb index 59073c27f..f95d59440 100644 --- a/spec/services/follow_service_spec.rb +++ b/spec/services/follow_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe FollowService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { FollowService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + context 'local account' do describe 'locked account' do let(:bob) { Fabricate(:account, locked: true, username: 'bob') } diff --git a/spec/services/process_mentions_service_spec.rb b/spec/services/process_mentions_service_spec.rb index 6a16928e0..79ccfa322 100644 --- a/spec/services/process_mentions_service_spec.rb +++ b/spec/services/process_mentions_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe ProcessMentionsService, type: :service do - let(:account) { Fabricate(:account, username: 'alice') } - subject { ProcessMentionsService.new } + let(:account) { Fabricate(:account, username: 'alice') } + context 'when mentions contain blocked accounts' do let(:non_blocked_account) { Fabricate(:account) } let(:individually_blocked_account) { Fabricate(:account) } diff --git a/spec/services/purge_domain_service_spec.rb b/spec/services/purge_domain_service_spec.rb index 59285f126..7d8969ee8 100644 --- a/spec/services/purge_domain_service_spec.rb +++ b/spec/services/purge_domain_service_spec.rb @@ -1,13 +1,13 @@ require 'rails_helper' RSpec.describe PurgeDomainService, type: :service do + subject { PurgeDomainService.new } + let!(:old_account) { Fabricate(:account, domain: 'obsolete.org') } let!(:old_status1) { Fabricate(:status, account: old_account) } let!(:old_status2) { Fabricate(:status, account: old_account) } let!(:old_attachment) { Fabricate(:media_attachment, account: old_account, status: old_status2, file: attachment_fixture('attachment.jpg')) } - subject { PurgeDomainService.new } - describe 'for a suspension' do before do subject.call('obsolete.org') diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb index c0ae5eedc..e2ac0154c 100644 --- a/spec/services/reblog_service_spec.rb +++ b/spec/services/reblog_service_spec.rb @@ -4,12 +4,12 @@ RSpec.describe ReblogService, type: :service do let(:alice) { Fabricate(:account, username: 'alice') } context 'creates a reblog with appropriate visibility' do + subject { ReblogService.new } + let(:visibility) { :public } let(:reblog_visibility) { :public } let(:status) { Fabricate(:status, account: alice, visibility: visibility) } - subject { ReblogService.new } - before do subject.call(alice, status, visibility: reblog_visibility) end @@ -45,11 +45,11 @@ RSpec.describe ReblogService, type: :service do end context 'ActivityPub' do + subject { ReblogService.new } + let(:bob) { Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } let(:status) { Fabricate(:status, account: bob) } - subject { ReblogService.new } - before do stub_request(:post, bob.inbox_url) allow(ActivityPub::DistributionWorker).to receive(:perform_async) diff --git a/spec/services/reject_follow_service_spec.rb b/spec/services/reject_follow_service_spec.rb index e14bfa78d..97b7412b9 100644 --- a/spec/services/reject_follow_service_spec.rb +++ b/spec/services/reject_follow_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe RejectFollowService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { RejectFollowService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account) } diff --git a/spec/services/remove_from_follwers_service_spec.rb b/spec/services/remove_from_follwers_service_spec.rb index 9b9c846cf..782f859e2 100644 --- a/spec/services/remove_from_follwers_service_spec.rb +++ b/spec/services/remove_from_follwers_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe RemoveFromFollowersService, type: :service do - let(:bob) { Fabricate(:account, username: 'bob') } - subject { RemoveFromFollowersService.new } + let(:bob) { Fabricate(:account, username: 'bob') } + describe 'local' do let(:sender) { Fabricate(:account, username: 'alice') } diff --git a/spec/services/report_service_spec.rb b/spec/services/report_service_spec.rb index 02bc42ac1..c3a3fddf8 100644 --- a/spec/services/report_service_spec.rb +++ b/spec/services/report_service_spec.rb @@ -29,13 +29,13 @@ RSpec.describe ReportService, type: :service do end context 'when the reported status is a DM' do - let(:target_account) { Fabricate(:account) } - let(:status) { Fabricate(:status, account: target_account, visibility: :direct) } - subject do -> { described_class.new.call(source_account, target_account, status_ids: [status.id]) } end + let(:target_account) { Fabricate(:account) } + let(:status) { Fabricate(:status, account: target_account, visibility: :direct) } + context 'when it is addressed to the reporter' do before do status.mentions.create(account: source_account) @@ -85,13 +85,13 @@ RSpec.describe ReportService, type: :service do end context 'when other reports already exist for the same target' do - let!(:target_account) { Fabricate(:account) } - let!(:other_report) { Fabricate(:report, target_account: target_account) } - subject do -> { described_class.new.call(source_account, target_account) } end + let!(:target_account) { Fabricate(:account) } + let!(:other_report) { Fabricate(:report, target_account: target_account) } + before do ActionMailer::Base.deliveries.clear source_account.user.settings.notification_emails['report'] = true diff --git a/spec/services/suspend_account_service_spec.rb b/spec/services/suspend_account_service_spec.rb index 126b13986..5701090b3 100644 --- a/spec/services/suspend_account_service_spec.rb +++ b/spec/services/suspend_account_service_spec.rb @@ -2,11 +2,11 @@ require 'rails_helper' RSpec.describe SuspendAccountService, type: :service do shared_examples 'common behavior' do + subject { described_class.new.call(account) } + let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account } let!(:list) { Fabricate(:list, account: local_follower) } - subject { described_class.new.call(account) } - before do allow(FeedManager.instance).to receive(:unmerge_from_home).and_return(nil) allow(FeedManager.instance).to receive(:unmerge_from_list).and_return(nil) diff --git a/spec/services/unallow_domain_service_spec.rb b/spec/services/unallow_domain_service_spec.rb index b93945b9a..ae7d00c7d 100644 --- a/spec/services/unallow_domain_service_spec.rb +++ b/spec/services/unallow_domain_service_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' RSpec.describe UnallowDomainService, type: :service do + subject { UnallowDomainService.new } + let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') } let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') } let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') } @@ -8,8 +10,6 @@ RSpec.describe UnallowDomainService, type: :service do let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) } let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') } - subject { UnallowDomainService.new } - context 'in limited federation mode' do before do allow(subject).to receive(:whitelist_mode?).and_return(true) diff --git a/spec/services/unblock_service_spec.rb b/spec/services/unblock_service_spec.rb index 10448b340..bd24005f6 100644 --- a/spec/services/unblock_service_spec.rb +++ b/spec/services/unblock_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe UnblockService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { UnblockService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account) } diff --git a/spec/services/unfollow_service_spec.rb b/spec/services/unfollow_service_spec.rb index bb5bef5c9..55969bef9 100644 --- a/spec/services/unfollow_service_spec.rb +++ b/spec/services/unfollow_service_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' RSpec.describe UnfollowService, type: :service do - let(:sender) { Fabricate(:account, username: 'alice') } - subject { UnfollowService.new } + let(:sender) { Fabricate(:account, username: 'alice') } + describe 'local' do let(:bob) { Fabricate(:account, username: 'bob') } diff --git a/spec/services/unsuspend_account_service_spec.rb b/spec/services/unsuspend_account_service_spec.rb index 987eb09e2..667507469 100644 --- a/spec/services/unsuspend_account_service_spec.rb +++ b/spec/services/unsuspend_account_service_spec.rb @@ -2,11 +2,11 @@ require 'rails_helper' RSpec.describe UnsuspendAccountService, type: :service do shared_examples 'common behavior' do + subject { described_class.new.call(account) } + let!(:local_follower) { Fabricate(:user, current_sign_in_at: 1.hour.ago).account } let!(:list) { Fabricate(:list, account: local_follower) } - subject { described_class.new.call(account) } - before do allow(FeedManager.instance).to receive(:merge_into_home).and_return(nil) allow(FeedManager.instance).to receive(:merge_into_list).and_return(nil) diff --git a/spec/validators/blacklisted_email_validator_spec.rb b/spec/validators/blacklisted_email_validator_spec.rb index cb807fe24..a642405ae 100644 --- a/spec/validators/blacklisted_email_validator_spec.rb +++ b/spec/validators/blacklisted_email_validator_spec.rb @@ -4,6 +4,8 @@ require 'rails_helper' RSpec.describe BlacklistedEmailValidator, type: :validator do describe '#validate' do + subject { described_class.new.validate(user); errors } + let(:user) { double(email: 'info@mail.com', sign_up_ip: '1.2.3.4', errors: errors) } let(:errors) { double(add: nil) } @@ -12,8 +14,6 @@ RSpec.describe BlacklistedEmailValidator, type: :validator do allow_any_instance_of(described_class).to receive(:blocked_email_provider?) { blocked_email } end - subject { described_class.new.validate(user); errors } - context 'when e-mail provider is blocked' do let(:blocked_email) { true } diff --git a/spec/workers/move_worker_spec.rb b/spec/workers/move_worker_spec.rb index 3ca6aaf4d..e93060adb 100644 --- a/spec/workers/move_worker_spec.rb +++ b/spec/workers/move_worker_spec.rb @@ -3,6 +3,8 @@ require 'rails_helper' describe MoveWorker do + subject { described_class.new } + let(:local_follower) { Fabricate(:account) } let(:blocking_account) { Fabricate(:account) } let(:muting_account) { Fabricate(:account) } @@ -14,8 +16,6 @@ describe MoveWorker do let(:block_service) { double } - subject { described_class.new } - before do local_follower.follow!(source_account) blocking_account.block!(source_account) diff --git a/spec/workers/unfollow_follow_worker_spec.rb b/spec/workers/unfollow_follow_worker_spec.rb index 5ea4256a9..8025b88c0 100644 --- a/spec/workers/unfollow_follow_worker_spec.rb +++ b/spec/workers/unfollow_follow_worker_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' describe UnfollowFollowWorker do + subject { described_class.new } + let(:local_follower) { Fabricate(:account) } let(:source_account) { Fabricate(:account) } let(:target_account) { Fabricate(:account) } let(:show_reblogs) { true } - subject { described_class.new } - before do local_follower.follow!(source_account, reblogs: show_reblogs) end -- cgit