From c55568c75a2754d1a2d9383b4e4e7147ea2e9ed5 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 13 Feb 2023 13:23:59 +0100 Subject: Add tests for `REST::AccountSerializer` (#23319) --- spec/serializers/rest/account_serializer_spec.rb | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/serializers/rest/account_serializer_spec.rb (limited to 'spec/serializers/rest/account_serializer_spec.rb') diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb new file mode 100644 index 000000000..ce29df3a7 --- /dev/null +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe REST::AccountSerializer do + 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! + end + + it 'returns empty roles' do + expect(subject['roles']).to eq [] + end + end + + context 'when the account has a highlighted role' do + let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } + + it 'returns the expected role' do + expect(subject['roles'].first).to include({ 'name' => 'Role' }) + end + end + + context 'when the account has a non-highlighted role' do + let(:role) { Fabricate(:user_role, name: 'Role', highlighted: false) } + + it 'returns empty roles' do + expect(subject['roles']).to eq [] + end + end +end -- cgit From 66f715550e575129e5d8b093a15aa67527136bd2 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 14 Feb 2023 13:50:55 +0100 Subject: Add `memorial` attribute to REST API (#23591) --- app/serializers/rest/account_serializer.rb | 8 +++++++- spec/serializers/rest/account_serializer_spec.rb | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'spec/serializers/rest/account_serializer_spec.rb') diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index f6fad9fe1..2845470be 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -16,6 +16,8 @@ class REST::AccountSerializer < ActiveModel::Serializer attribute :silenced, key: :limited, if: :silenced? attribute :noindex, if: :local? + attribute :memorial, if: :memorial? + class AccountDecorator < SimpleDelegator def self.model_name Account.model_name @@ -124,6 +126,10 @@ class REST::AccountSerializer < ActiveModel::Serializer object.silenced? end + def memorial + object.memorial? + end + def roles if object.suspended? || object.user.nil? [] @@ -136,7 +142,7 @@ class REST::AccountSerializer < ActiveModel::Serializer object.user_prefers_noindex? end - delegate :suspended?, :silenced?, :local?, to: :object + delegate :suspended?, :silenced?, :local?, :memorial?, to: :object def moved_and_not_nested? object.moved? diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index ce29df3a7..5b08d5aca 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -34,4 +34,14 @@ describe REST::AccountSerializer do expect(subject['roles']).to eq [] end end + + context 'when the account is memorialized' do + before do + account.memorialize! + end + + it 'marks it as such' do + expect(subject['memorial']).to be true + end + end end -- cgit From 669f6d2c0af969268c76e389ed626bce0cc9f998 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Fri, 17 Feb 2023 16:56:20 -0500 Subject: Run rubocop formatting except line length (#23632) --- .rubocop_todo.yml | 277 +-------------------- app/lib/activitypub/activity/create.rb | 4 +- app/models/concerns/expireable.rb | 2 +- app/services/activitypub/fetch_replies_service.rb | 2 +- .../20161006213403_rails_settings_migration.rb | 10 +- ...uses_for_api_v1_accounts_account_id_statuses.rb | 8 +- .../20190306145741_add_lock_version_to_polls.rb | 1 - ...20190807135426_add_comments_to_domain_blocks.rb | 1 - ...200312162302_add_status_ids_to_announcements.rb | 1 - ...00510181721_remove_duplicated_indexes_pghero.rb | 1 - db/migrate/20200628133322_create_account_notes.rb | 1 - ...340_create_account_statuses_cleanup_policies.rb | 1 - ...0729171123_fix_custom_filter_keywords_id_seq.rb | 2 +- lib/paperclip/attachment_extensions.rb | 10 +- lib/tasks/mastodon.rake | 4 +- spec/config/initializers/rack_attack_spec.rb | 10 +- .../controllers/admin/dashboard_controller_spec.rb | 8 +- .../api/v1/accounts/credentials_controller_spec.rb | 2 +- spec/controllers/api/v1/reports_controller_spec.rb | 2 +- .../favourited_by_accounts_controller_spec.rb | 2 +- .../reblogged_by_accounts_controller_spec.rb | 2 +- .../api/v2/filters/statuses_controller_spec.rb | 4 +- spec/controllers/auth/sessions_controller_spec.rb | 6 +- .../authorize_interactions_controller_spec.rb | 1 - .../settings/applications_controller_spec.rb | 2 +- .../confirmations_controller_spec.rb | 1 - .../webauthn_credentials_controller_spec.rb | 2 +- .../well_known/host_meta_controller_spec.rb | 12 +- .../custom_filter_keyword_fabricator.rb | 2 +- spec/fabricators/ip_block_fabricator.rb | 2 +- spec/fabricators/poll_vote_fabricator.rb | 2 +- spec/fabricators/status_edit_fabricator.rb | 2 +- spec/fabricators/system_key_fabricator.rb | 1 - spec/lib/activitypub/activity/create_spec.rb | 1 - spec/lib/extractor_spec.rb | 8 +- spec/lib/fast_ip_map_spec.rb | 2 +- spec/lib/link_details_extractor_spec.rb | 124 ++++----- spec/models/account/field_spec.rb | 4 +- spec/models/account_alias_spec.rb | 1 - .../models/account_statuses_cleanup_policy_spec.rb | 40 ++- spec/models/concerns/account_interactions_spec.rb | 2 +- spec/models/device_spec.rb | 1 - spec/models/encrypted_message_spec.rb | 1 - spec/models/export_spec.rb | 2 +- spec/models/login_activity_spec.rb | 1 - spec/models/one_time_key_spec.rb | 1 - spec/models/system_key_spec.rb | 1 - spec/models/trends/statuses_spec.rb | 2 +- spec/models/user_role_spec.rb | 2 +- spec/routing/api_routing_spec.rb | 72 +++--- spec/routing/well_known_routes_spec.rb | 8 +- spec/serializers/rest/account_serializer_spec.rb | 2 +- .../account_statuses_cleanup_service_spec.rb | 4 +- .../fetch_remote_status_service_spec.rb | 2 +- .../activitypub/process_account_service_spec.rb | 4 +- .../activitypub/process_collection_service_spec.rb | 12 +- .../process_status_update_service_spec.rb | 42 ++-- spec/services/bootstrap_timeline_service_spec.rb | 1 - spec/services/fetch_oembed_service_spec.rb | 1 - spec/services/import_service_spec.rb | 4 +- spec/services/remove_from_follwers_service_spec.rb | 2 +- spec/services/remove_status_service_spec.rb | 68 ++--- spec/services/resolve_account_service_spec.rb | 2 +- spec/services/resolve_url_service_spec.rb | 2 +- spec/services/update_status_service_spec.rb | 2 +- spec/support/stories/profile_stories.rb | 4 +- spec/validators/note_length_validator_spec.rb | 4 +- .../unreserved_username_validator_spec.rb | 6 +- .../activitypub/distribution_worker_spec.rb | 2 +- .../activitypub/move_distribution_worker_spec.rb | 8 +- .../accounts_statuses_cleanup_scheduler_spec.rb | 2 +- 71 files changed, 269 insertions(+), 566 deletions(-) (limited to 'spec/serializers/rest/account_serializer_spec.rb') diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e3a42da5b..e24ce7e32 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit` -# on 2023-02-16 04:55:24 UTC using RuboCop version 1.45.1. +# on 2023-02-16 05:53:07 UTC using RuboCop version 1.45.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -14,53 +14,6 @@ Bundler/OrderedGems: Exclude: - 'Gemfile' -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/ArgumentAlignment: - Exclude: - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/ClosingParenthesisIndentation: - Exclude: - - 'spec/controllers/auth/sessions_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/CommentIndentation: - Exclude: - - 'db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb' - -# Offense count: 22 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Exclude: - - 'lib/paperclip/attachment_extensions.rb' - - 'spec/routing/api_routing_spec.rb' - - 'spec/routing/well_known_routes_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/ElseAlignment: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - # Offense count: 81 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterGuardClause: @@ -183,73 +136,6 @@ Layout/EmptyLineAfterMagicComment: - 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb' - 'spec/models/tag_spec.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLines: - Exclude: - - 'spec/controllers/authorize_interactions_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb' - - 'spec/lib/activitypub/activity/create_spec.rb' - -# Offense count: 9 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, no_empty_lines -Layout/EmptyLinesAroundBlockBody: - Exclude: - - 'spec/fabricators/system_key_fabricator.rb' - - 'spec/models/account_alias_spec.rb' - - 'spec/models/device_spec.rb' - - 'spec/models/encrypted_message_spec.rb' - - 'spec/models/login_activity_spec.rb' - - 'spec/models/one_time_key_spec.rb' - - 'spec/models/system_key_spec.rb' - - 'spec/services/bootstrap_timeline_service_spec.rb' - - 'spec/services/fetch_oembed_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith, Severity. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Layout/EndAlignment: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'spec/config/initializers/rack_attack_spec.rb' - - 'spec/controllers/api/v2/filters/statuses_controller_spec.rb' - - 'spec/fabricators/custom_filter_keyword_fabricator.rb' - - 'spec/fabricators/poll_vote_fabricator.rb' - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - - 'spec/services/import_service_spec.rb' - - 'spec/services/resolve_account_service_spec.rb' - - 'spec/services/resolve_url_service_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - - 'spec/validators/unreserved_username_validator_spec.rb' - - 'spec/workers/activitypub/move_distribution_worker_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'spec/services/remove_status_service_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/FirstArrayElementIndentation: - Exclude: - - 'spec/controllers/admin/dashboard_controller_spec.rb' - - 'spec/workers/activitypub/move_distribution_worker_spec.rb' - # Offense count: 113 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. @@ -276,49 +162,6 @@ Layout/HashAlignment: - 'spec/models/admin/account_action_spec.rb' - 'spec/models/concerns/account_interactions_spec.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -Layout/HeredocIndentation: - Exclude: - - 'spec/controllers/well_known/host_meta_controller_spec.rb' - - 'spec/lib/link_details_extractor_spec.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, indented_internal_methods -Layout/IndentationConsistency: - Exclude: - - 'spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb' - - 'spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb' - - 'spec/models/trends/statuses_spec.rb' - - 'spec/services/import_service_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - - 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb' - - 'spec/services/account_statuses_cleanup_service_spec.rb' - - 'spec/services/import_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. -Layout/LeadingCommentSpace: - Exclude: - - 'lib/paperclip/attachment_extensions.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, EnforcedStyle. -# SupportedStyles: space, no_space -Layout/LineContinuationSpacing: - Exclude: - - 'spec/support/stories/profile_stories.rb' - # Offense count: 577 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. @@ -326,124 +169,6 @@ Layout/LineContinuationSpacing: Layout/LineLength: Enabled: false -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'spec/models/account_statuses_cleanup_policy_spec.rb' - - 'spec/services/activitypub/process_status_update_service_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. -# SupportedStylesForExponentOperator: space, no_space -Layout/SpaceAroundOperators: - Exclude: - - 'spec/services/activitypub/fetch_remote_status_service_spec.rb' - - 'spec/validators/note_length_validator_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceBeforeBlockBraces: - Exclude: - - 'spec/controllers/api/v1/reports_controller_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/fabricators/custom_filter_keyword_fabricator.rb' - - 'spec/fabricators/poll_vote_fabricator.rb' - - 'spec/models/concerns/account_interactions_spec.rb' - -# Offense count: 24 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'db/migrate/20161006213403_rails_settings_migration.rb' - - 'spec/controllers/settings/applications_controller_spec.rb' - - 'spec/lib/extractor_spec.rb' - - 'spec/models/export_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - - 'spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'spec/lib/fast_ip_map_spec.rb' - - 'spec/models/user_role_spec.rb' - - 'spec/serializers/rest/account_serializer_spec.rb' - - 'spec/workers/activitypub/distribution_worker_spec.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'app/lib/activitypub/activity/create.rb' - - 'app/services/activitypub/fetch_replies_service.rb' - - 'spec/services/activitypub/process_collection_service_spec.rb' - - 'spec/services/update_status_service_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, compact, no_space -Layout/SpaceInsideParens: - Exclude: - - 'spec/validators/unreserved_username_validator_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideStringInterpolation: - Exclude: - - 'spec/controllers/auth/sessions_controller_spec.rb' - - 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' - - 'spec/services/activitypub/process_account_service_spec.rb' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: final_newline, final_blank_line -Layout/TrailingEmptyLines: - Exclude: - - 'db/migrate/20190306145741_add_lock_version_to_polls.rb' - - 'db/migrate/20190807135426_add_comments_to_domain_blocks.rb' - - 'db/migrate/20200312162302_add_status_ids_to_announcements.rb' - - 'db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb' - - 'db/migrate/20200628133322_create_account_notes.rb' - - 'db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb' - - 'spec/fabricators/ip_block_fabricator.rb' - - 'spec/fabricators/status_edit_fabricator.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'app/models/concerns/expireable.rb' - - 'db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb' - - 'lib/tasks/mastodon.rake' - - 'spec/models/account/field_spec.rb' - - 'spec/services/remove_from_follwers_service_spec.rb' - # Offense count: 14 # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 487b65223..f82112c02 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -327,7 +327,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity def resolve_thread(status) return unless status.reply? && status.thread.nil? && Request.valid_url?(in_reply_to_uri) - ThreadResolveWorker.perform_async(status.id, in_reply_to_uri, { 'request_id' => @options[:request_id]}) + ThreadResolveWorker.perform_async(status.id, in_reply_to_uri, { 'request_id' => @options[:request_id] }) end def fetch_replies(status) @@ -338,7 +338,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity return unless replies.nil? uri = value_or_id(collection) - ActivityPub::FetchRepliesWorker.perform_async(status.id, uri, { 'request_id' => @options[:request_id]}) unless uri.nil? + ActivityPub::FetchRepliesWorker.perform_async(status.id, uri, { 'request_id' => @options[:request_id] }) unless uri.nil? end def conversation_from_uri(uri) diff --git a/app/models/concerns/expireable.rb b/app/models/concerns/expireable.rb index 4d902abcb..c64fc7d80 100644 --- a/app/models/concerns/expireable.rb +++ b/app/models/concerns/expireable.rb @@ -17,7 +17,7 @@ module Expireable end def expires_in=(interval) - self.expires_at = interval.present? ? interval.to_i.seconds.from_now : nil + self.expires_at = interval.present? ? interval.to_i.seconds.from_now : nil @expires_in = interval end diff --git a/app/services/activitypub/fetch_replies_service.rb b/app/services/activitypub/fetch_replies_service.rb index 18a27e851..4128df9ca 100644 --- a/app/services/activitypub/fetch_replies_service.rb +++ b/app/services/activitypub/fetch_replies_service.rb @@ -10,7 +10,7 @@ class ActivityPub::FetchRepliesService < BaseService @items = collection_items(collection_or_uri) return if @items.nil? - FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id}] } + FetchReplyWorker.push_bulk(filtered_replies) { |reply_uri| [reply_uri, { 'request_id' => request_id }] } @items end diff --git a/db/migrate/20161006213403_rails_settings_migration.rb b/db/migrate/20161006213403_rails_settings_migration.rb index 9d565cb5c..02932610c 100644 --- a/db/migrate/20161006213403_rails_settings_migration.rb +++ b/db/migrate/20161006213403_rails_settings_migration.rb @@ -1,8 +1,8 @@ MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5 - ActiveRecord::Migration[5.0] -else - ActiveRecord::Migration[4.2] -end + ActiveRecord::Migration[5.0] + else + ActiveRecord::Migration[4.2] + end class RailsSettingsMigration < MIGRATION_BASE_CLASS def self.up @@ -12,7 +12,7 @@ class RailsSettingsMigration < MIGRATION_BASE_CLASS t.references :target, null: false, polymorphic: true, index: { name: 'index_settings_on_target_type_and_target_id' } t.timestamps null: true end - add_index :settings, [ :target_type, :target_id, :var ], unique: true + add_index :settings, [:target_type, :target_id, :var], unique: true end def self.down diff --git a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb index b29e62803..a3f883fcb 100644 --- a/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb +++ b/db/migrate/20180514130000_improve_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb @@ -4,9 +4,9 @@ class ImproveIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Mi disable_ddl_transaction! def change - # These changes ware reverted by migration 20180514140000. - # add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently - # add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently - # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 + # These changes ware reverted by migration 20180514140000. + # add_index :statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently + # add_index :statuses, [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently + # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106 end end diff --git a/db/migrate/20190306145741_add_lock_version_to_polls.rb b/db/migrate/20190306145741_add_lock_version_to_polls.rb index 5bb8cd3b4..c9fa471ad 100644 --- a/db/migrate/20190306145741_add_lock_version_to_polls.rb +++ b/db/migrate/20190306145741_add_lock_version_to_polls.rb @@ -21,4 +21,3 @@ class AddLockVersionToPolls < ActiveRecord::Migration[5.2] remove_column :polls, :lock_version end end - diff --git a/db/migrate/20190807135426_add_comments_to_domain_blocks.rb b/db/migrate/20190807135426_add_comments_to_domain_blocks.rb index b660a71ad..79b9f0212 100644 --- a/db/migrate/20190807135426_add_comments_to_domain_blocks.rb +++ b/db/migrate/20190807135426_add_comments_to_domain_blocks.rb @@ -4,4 +4,3 @@ class AddCommentsToDomainBlocks < ActiveRecord::Migration[5.2] add_column :domain_blocks, :public_comment, :text end end - diff --git a/db/migrate/20200312162302_add_status_ids_to_announcements.rb b/db/migrate/20200312162302_add_status_ids_to_announcements.rb index 42aa6513d..704d3773e 100644 --- a/db/migrate/20200312162302_add_status_ids_to_announcements.rb +++ b/db/migrate/20200312162302_add_status_ids_to_announcements.rb @@ -3,4 +3,3 @@ class AddStatusIdsToAnnouncements < ActiveRecord::Migration[5.2] add_column :announcements, :status_ids, :bigint, array: true end end - diff --git a/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb b/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb index 1d6ba1fe9..59bb1b9e2 100644 --- a/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb +++ b/db/migrate/20200510181721_remove_duplicated_indexes_pghero.rb @@ -19,4 +19,3 @@ class RemoveDuplicatedIndexesPghero < ActiveRecord::Migration[5.2] add_index :markers, :user_id, name: :index_markers_on_user_id unless index_exists?(:markers, :user_id, name: :index_markers_on_user_id) end end - diff --git a/db/migrate/20200628133322_create_account_notes.rb b/db/migrate/20200628133322_create_account_notes.rb index 664727e60..022e0ff3a 100644 --- a/db/migrate/20200628133322_create_account_notes.rb +++ b/db/migrate/20200628133322_create_account_notes.rb @@ -10,4 +10,3 @@ class CreateAccountNotes < ActiveRecord::Migration[5.2] end end end - diff --git a/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb b/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb index 28cfb6ef5..db168676a 100644 --- a/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb +++ b/db/migrate/20210722120340_create_account_statuses_cleanup_policies.rb @@ -17,4 +17,3 @@ class CreateAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1] end end end - diff --git a/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb b/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb index 7ed34a3ef..eb437c86c 100644 --- a/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb +++ b/db/post_migrate/20220729171123_fix_custom_filter_keywords_id_seq.rb @@ -5,7 +5,7 @@ class FixCustomFilterKeywordsIdSeq < ActiveRecord::Migration[6.1] def up # 20220613110711 manually inserts items with set `id` in the database, but - # we also need to bump the sequence number, otherwise + # we also need to bump the sequence number, otherwise safety_assured do execute <<-SQL.squish BEGIN; diff --git a/lib/paperclip/attachment_extensions.rb b/lib/paperclip/attachment_extensions.rb index d66a17623..7f82138aa 100644 --- a/lib/paperclip/attachment_extensions.rb +++ b/lib/paperclip/attachment_extensions.rb @@ -8,7 +8,7 @@ module Paperclip # monkey-patch to avoid unlinking too avoid unlinking source file too early # see https://github.com/kreeti/kt-paperclip/issues/64 - def post_process_style(name, style) #:nodoc: + def post_process_style(name, style) # :nodoc: raise "Style #{name} has no processors defined." if style.processors.blank? intermediate_files = [] @@ -16,16 +16,16 @@ module Paperclip # if we're processing the original, close + unlink the source tempfile intermediate_files << original if name == :original - @queued_for_write[name] = style.processors. - inject(original) do |file, processor| + @queued_for_write[name] = style.processors + .inject(original) do |file, processor| file = Paperclip.processor(processor).make(file, style.processor_options, self) intermediate_files << file unless file == original file end unadapted_file = @queued_for_write[name] - @queued_for_write[name] = Paperclip.io_adapters. - for(@queued_for_write[name], @options[:adapter_options]) + @queued_for_write[name] = Paperclip.io_adapters + .for(@queued_for_write[name], @options[:adapter_options]) unadapted_file.close if unadapted_file.respond_to?(:close) @queued_for_write[name] rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 1184e5273..477daa01b 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -286,13 +286,13 @@ namespace :mastodon do q.required true q.modify :strip end - + linksharing_access_key = prompt.ask('Storj Linksharing access key (uplink share --register --public --readonly=true --disallow-lists --not-after=none sj://bucket):') do |q| q.required true q.modify :strip end env['S3_ALIAS_HOST'] = "link.storjshare.io/raw/#{linksharing_access_key}/#{env['S3_BUCKET']}" - + when 'Google Cloud Storage' env['S3_ENABLED'] = 'true' env['S3_PROTOCOL'] = 'https' diff --git a/spec/config/initializers/rack_attack_spec.rb b/spec/config/initializers/rack_attack_spec.rb index 581021cb9..03695f5fd 100644 --- a/spec/config/initializers/rack_attack_spec.rb +++ b/spec/config/initializers/rack_attack_spec.rb @@ -35,12 +35,12 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/auth' } + let(:path) { '/auth' } it_behaves_like 'throttled endpoint' end context 'for path with format' do - let(:path) { '/auth.html' } + let(:path) { '/auth.html' } it_behaves_like 'throttled endpoint' end end @@ -50,7 +50,7 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/api/v1/accounts' } + let(:path) { '/api/v1/accounts' } it_behaves_like 'throttled endpoint' end @@ -70,12 +70,12 @@ describe Rack::Attack do let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } context 'for exact path' do - let(:path) { '/auth/sign_in' } + let(:path) { '/auth/sign_in' } it_behaves_like 'throttled endpoint' end context 'for path with format' do - let(:path) { '/auth/sign_in.html' } + let(:path) { '/auth/sign_in.html' } it_behaves_like 'throttled endpoint' end end diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 6231a09a2..ab3738fcd 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -8,10 +8,10 @@ describe Admin::DashboardController, type: :controller do describe 'GET #index' do before do allow(Admin::SystemCheck).to receive(:perform).and_return([ - Admin::SystemCheck::Message.new(:database_schema_check), - Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path), - Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'), - ]) + Admin::SystemCheck::Message.new(:database_schema_check), + Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path), + Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'), + ]) sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) end diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index b2557d957..89cc8acad 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -70,7 +70,7 @@ describe Api::V1::Accounts::CredentialsController do it 'returns http success' do expect(response).to have_http_status(200) end - end + end describe 'with invalid data' do before do diff --git a/spec/controllers/api/v1/reports_controller_spec.rb b/spec/controllers/api/v1/reports_controller_spec.rb index dbc64e704..78a72b95b 100644 --- a/spec/controllers/api/v1/reports_controller_spec.rb +++ b/spec/controllers/api/v1/reports_controller_spec.rb @@ -20,7 +20,7 @@ RSpec.describe Api::V1::ReportsController, type: :controller do let(:target_account) { status.account } let(:category) { nil } let(:forward) { nil } - let(:rule_ids){ nil } + let(:rule_ids) { nil } before do allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil)) diff --git a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb index 7cc77f430..4dcaba6bd 100644 --- a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control it 'returns accounts who favorited the status' do get :index, params: { status_id: status.id, limit: 2 } expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) + expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) end it 'does not return blocked users' do diff --git a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb index 8d4a6f91c..dc36d4ca0 100644 --- a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll it 'returns accounts who reblogged the status' do get :index, params: { status_id: status.id, limit: 2 } expect(body_as_json.size).to eq 2 - expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) + expect([body_as_json[0][:id], body_as_json[1][:id]]).to match_array([alice.id.to_s, bob.id.to_s]) end it 'does not return blocked users' do diff --git a/spec/controllers/api/v2/filters/statuses_controller_spec.rb b/spec/controllers/api/v2/filters/statuses_controller_spec.rb index 9740c1eb3..969b2ea73 100644 --- a/spec/controllers/api/v2/filters/statuses_controller_spec.rb +++ b/spec/controllers/api/v2/filters/statuses_controller_spec.rb @@ -64,7 +64,7 @@ RSpec.describe Api::V2::Filters::StatusesController, type: :controller do end describe 'GET #show' do - let(:scopes) { 'read:filters' } + let(:scopes) { 'read:filters' } let!(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) } before do @@ -90,7 +90,7 @@ RSpec.describe Api::V2::Filters::StatusesController, type: :controller do end describe 'DELETE #destroy' do - let(:scopes) { 'write:filters' } + let(:scopes) { 'write:filters' } let(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) } before do diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index d3db7aa1a..64433ddf4 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -339,11 +339,11 @@ RSpec.describe Auth::SessionsController, type: :controller do external_id: public_key_credential.id, public_key: public_key_credential.public_key, sign_count: '1000' - ) + ) user.webauthn_credentials.take end - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } @@ -400,7 +400,7 @@ RSpec.describe Auth::SessionsController, type: :controller do describe 'GET #webauthn_options' do context 'with WebAuthn and OTP enabled as second factor' do - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } diff --git a/spec/controllers/authorize_interactions_controller_spec.rb b/spec/controllers/authorize_interactions_controller_spec.rb index 44f52df69..e52103941 100644 --- a/spec/controllers/authorize_interactions_controller_spec.rb +++ b/spec/controllers/authorize_interactions_controller_spec.rb @@ -99,7 +99,6 @@ describe AuthorizeInteractionsController do allow(ResolveAccountService).to receive(:new).and_return(service) allow(service).to receive(:call).with('user@hostname').and_return(target_account) - post :create, params: { acct: 'acct:user@hostname' } expect(account.following?(target_account)).to be true diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index 1292e9ff8..9074574e4 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -73,7 +73,7 @@ describe Settings::ApplicationsController do name: 'My New App', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', website: 'http://google.com', - scopes: [ 'read', 'write', 'follow' ] + scopes: ['read', 'write', 'follow'] } } response diff --git a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb index 569c8322b..0b807b280 100644 --- a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb @@ -5,7 +5,6 @@ require 'rails_helper' describe Settings::TwoFactorAuthentication::ConfirmationsController do render_views - shared_examples 'renders :new' do it 'renders the new view' do subject diff --git a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb index fe53b4dfc..06989ffd2 100644 --- a/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb @@ -7,7 +7,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do render_views let(:user) { Fabricate(:user) } - let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http' }://#{Rails.configuration.x.web_domain}" } + let(:domain) { "#{Rails.configuration.x.use_https ? 'https' : 'http'}://#{Rails.configuration.x.web_domain}" } let(:fake_client) { WebAuthn::FakeClient.new(domain) } def add_webauthn_credential(user) diff --git a/spec/controllers/well_known/host_meta_controller_spec.rb b/spec/controllers/well_known/host_meta_controller_spec.rb index c02aa0d59..654bad406 100644 --- a/spec/controllers/well_known/host_meta_controller_spec.rb +++ b/spec/controllers/well_known/host_meta_controller_spec.rb @@ -9,12 +9,12 @@ describe WellKnown::HostMetaController, type: :controller do expect(response).to have_http_status(200) expect(response.media_type).to eq 'application/xrd+xml' - expect(response.body).to eq < - - - -XML + expect(response.body).to eq <<~XML + + + + + XML end end end diff --git a/spec/fabricators/custom_filter_keyword_fabricator.rb b/spec/fabricators/custom_filter_keyword_fabricator.rb index 0f101dcd1..201566cbe 100644 --- a/spec/fabricators/custom_filter_keyword_fabricator.rb +++ b/spec/fabricators/custom_filter_keyword_fabricator.rb @@ -1,4 +1,4 @@ Fabricator(:custom_filter_keyword) do custom_filter - keyword 'discourse' + keyword 'discourse' end diff --git a/spec/fabricators/ip_block_fabricator.rb b/spec/fabricators/ip_block_fabricator.rb index 31dc336e6..1797f6877 100644 --- a/spec/fabricators/ip_block_fabricator.rb +++ b/spec/fabricators/ip_block_fabricator.rb @@ -3,4 +3,4 @@ Fabricator(:ip_block) do severity "" expires_at "2020-10-08 22:20:37" comment "MyText" -end \ No newline at end of file +end diff --git a/spec/fabricators/poll_vote_fabricator.rb b/spec/fabricators/poll_vote_fabricator.rb index 51f9b006e..c06e61f67 100644 --- a/spec/fabricators/poll_vote_fabricator.rb +++ b/spec/fabricators/poll_vote_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:poll_vote) do account poll - choice 0 + choice 0 end diff --git a/spec/fabricators/status_edit_fabricator.rb b/spec/fabricators/status_edit_fabricator.rb index 21b793747..3141759e5 100644 --- a/spec/fabricators/status_edit_fabricator.rb +++ b/spec/fabricators/status_edit_fabricator.rb @@ -4,4 +4,4 @@ Fabricator(:status_edit) do text "MyText" spoiler_text "MyText" media_attachments_changed false -end \ No newline at end of file +end diff --git a/spec/fabricators/system_key_fabricator.rb b/spec/fabricators/system_key_fabricator.rb index f808495e0..c744bb286 100644 --- a/spec/fabricators/system_key_fabricator.rb +++ b/spec/fabricators/system_key_fabricator.rb @@ -1,3 +1,2 @@ Fabricator(:system_key) do - end diff --git a/spec/lib/activitypub/activity/create_spec.rb b/spec/lib/activitypub/activity/create_spec.rb index 1a25395fa..cd0f2df6e 100644 --- a/spec/lib/activitypub/activity/create_spec.rb +++ b/spec/lib/activitypub/activity/create_spec.rb @@ -408,7 +408,6 @@ RSpec.describe ActivityPub::Activity::Create do end end - context 'with media attachments with long description' do let(:object_json) do { diff --git a/spec/lib/extractor_spec.rb b/spec/lib/extractor_spec.rb index dba4bd0bb..9c9f5ef04 100644 --- a/spec/lib/extractor_spec.rb +++ b/spec/lib/extractor_spec.rb @@ -20,7 +20,7 @@ describe Extractor do text = '@screen_name' extracted = Extractor.extract_mentions_or_lists_with_indices(text) expect(extracted).to eq [ - { screen_name: 'screen_name', indices: [ 0, 12 ] } + { screen_name: 'screen_name', indices: [0, 12] } ] end @@ -44,19 +44,19 @@ describe Extractor do it 'does not exclude normal hash text before ://' do text = '#hashtag://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'excludes http://' do text = '#hashtaghttp://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'excludes https://' do text = '#hashtaghttps://' extracted = Extractor.extract_hashtags_with_indices(text) - expect(extracted).to eq [ { hashtag: 'hashtag', indices: [ 0, 8 ] } ] + expect(extracted).to eq [{ hashtag: 'hashtag', indices: [0, 8] }] end it 'yields hashtags if a block is given' do diff --git a/spec/lib/fast_ip_map_spec.rb b/spec/lib/fast_ip_map_spec.rb index c66f64828..78b3ddb05 100644 --- a/spec/lib/fast_ip_map_spec.rb +++ b/spec/lib/fast_ip_map_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' describe FastIpMap do describe '#include?' do - subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')])} + subject { described_class.new([IPAddr.new('20.4.0.0/16'), IPAddr.new('145.22.30.0/24'), IPAddr.new('189.45.86.3')]) } it 'returns true for an exact match' do expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true diff --git a/spec/lib/link_details_extractor_spec.rb b/spec/lib/link_details_extractor_spec.rb index 7ea867c61..7eb15ced3 100644 --- a/spec/lib/link_details_extractor_spec.rb +++ b/spec/lib/link_details_extractor_spec.rb @@ -39,17 +39,17 @@ RSpec.describe LinkDetailsExtractor do let(:original_url) { 'https://example.com/page.html' } context 'and is wrapped in CDATA tags' do - let(:html) { <<-HTML } - - - - - - + let(:html) { <<~HTML } + + + + + + HTML describe '#title' do @@ -78,57 +78,57 @@ RSpec.describe LinkDetailsExtractor do end context 'but the first tag is invalid JSON' do - let(:html) { <<-HTML } - - - - - - - + let(:html) { <<~HTML } + + + + + + + HTML describe '#title' do diff --git a/spec/models/account/field_spec.rb b/spec/models/account/field_spec.rb index 0ac9769bc..40bbee025 100644 --- a/spec/models/account/field_spec.rb +++ b/spec/models/account/field_spec.rb @@ -97,7 +97,7 @@ RSpec.describe Account::Field, type: :model do expect(subject.verifiable?).to be false end end - + context 'for text which is blank' do let(:value) { '' } @@ -149,7 +149,7 @@ RSpec.describe Account::Field, type: :model do expect(subject.verifiable?).to be false end end - + context 'for text which is blank' do let(:value) { '' } diff --git a/spec/models/account_alias_spec.rb b/spec/models/account_alias_spec.rb index 27ec215aa..c48b804b2 100644 --- a/spec/models/account_alias_spec.rb +++ b/spec/models/account_alias_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe AccountAlias, type: :model do - end diff --git a/spec/models/account_statuses_cleanup_policy_spec.rb b/spec/models/account_statuses_cleanup_policy_spec.rb index 684a1aa41..f11684516 100644 --- a/spec/models/account_statuses_cleanup_policy_spec.rb +++ b/spec/models/account_statuses_cleanup_policy_spec.rb @@ -16,16 +16,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do context 'when widening a policy' do let!(:account_statuses_cleanup_policy) do Fabricate(:account_statuses_cleanup_policy, - account: account, - keep_direct: true, - keep_pinned: true, - keep_polls: true, - keep_media: true, - keep_self_fav: true, - keep_self_bookmark: true, - min_favs: 1, - min_reblogs: 1 - ) + account: account, + keep_direct: true, + keep_pinned: true, + keep_polls: true, + keep_media: true, + keep_self_fav: true, + keep_self_bookmark: true, + min_favs: 1, + min_reblogs: 1) end before do @@ -96,16 +95,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do context 'when narrowing a policy' do let!(:account_statuses_cleanup_policy) do Fabricate(:account_statuses_cleanup_policy, - account: account, - keep_direct: false, - keep_pinned: false, - keep_polls: false, - keep_media: false, - keep_self_fav: false, - keep_self_bookmark: false, - min_favs: nil, - min_reblogs: nil - ) + account: account, + keep_direct: false, + keep_pinned: false, + keep_polls: false, + keep_media: false, + keep_self_fav: false, + keep_self_bookmark: false, + min_favs: nil, + min_reblogs: nil) end it 'does not unnecessarily invalidate last_inspected' do @@ -232,7 +230,7 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do end describe '#compute_cutoff_id' do - let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) } + 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 } diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index 5cb4a83f7..e628384d0 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -400,7 +400,7 @@ describe AccountInteractions do subject { account.domain_blocking?(domain) } context 'blocking the domain' do - it' returns true' do + it ' returns true' do account_domain_block = Fabricate(:account_domain_block, domain: domain) account.domain_blocks << account_domain_block is_expected.to be true diff --git a/spec/models/device_spec.rb b/spec/models/device_spec.rb index f56fbf978..307552e91 100644 --- a/spec/models/device_spec.rb +++ b/spec/models/device_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe Device, type: :model do - end diff --git a/spec/models/encrypted_message_spec.rb b/spec/models/encrypted_message_spec.rb index 1238d57b6..64f9c6912 100644 --- a/spec/models/encrypted_message_spec.rb +++ b/spec/models/encrypted_message_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe EncryptedMessage, type: :model do - end diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb index 135d7a36b..5202ae9e1 100644 --- a/spec/models/export_spec.rb +++ b/spec/models/export_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe Export do let(:account) { Fabricate(:account) } let(:target_accounts) do - [ {}, { username: 'one', domain: 'local.host' } ].map(&method(:Fabricate).curry(2).call(:account)) + [{}, { username: 'one', domain: 'local.host' }].map(&method(:Fabricate).curry(2).call(:account)) end describe 'to_csv' do diff --git a/spec/models/login_activity_spec.rb b/spec/models/login_activity_spec.rb index ba2d207c9..12d8c4363 100644 --- a/spec/models/login_activity_spec.rb +++ b/spec/models/login_activity_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe LoginActivity, type: :model do - end diff --git a/spec/models/one_time_key_spec.rb b/spec/models/one_time_key_spec.rb index 34598334c..4b231c600 100644 --- a/spec/models/one_time_key_spec.rb +++ b/spec/models/one_time_key_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe OneTimeKey, type: :model do - end diff --git a/spec/models/system_key_spec.rb b/spec/models/system_key_spec.rb index a138bc131..86f07f964 100644 --- a/spec/models/system_key_spec.rb +++ b/spec/models/system_key_spec.rb @@ -1,5 +1,4 @@ require 'rails_helper' RSpec.describe SystemKey, type: :model do - end diff --git a/spec/models/trends/statuses_spec.rb b/spec/models/trends/statuses_spec.rb index 5f338a65e..98a8c7264 100644 --- a/spec/models/trends/statuses_spec.rb +++ b/spec/models/trends/statuses_spec.rb @@ -76,7 +76,7 @@ RSpec.describe Trends::Statuses do before do 13.times { reblog(status1, today) } 13.times { reblog(status2, today) } - 4.times { reblog(status3, today) } + 4.times { reblog(status3, today) } end context do diff --git a/spec/models/user_role_spec.rb b/spec/models/user_role_spec.rb index 28019593e..abf7d0e27 100644 --- a/spec/models/user_role_spec.rb +++ b/spec/models/user_role_spec.rb @@ -58,7 +58,7 @@ RSpec.describe UserRole, type: :model do end describe '#permissions_as_keys=' do - let(:input) { } + let(:input) {} before do subject.permissions_as_keys = input diff --git a/spec/routing/api_routing_spec.rb b/spec/routing/api_routing_spec.rb index 2683ccb8d..a822fba4c 100644 --- a/spec/routing/api_routing_spec.rb +++ b/spec/routing/api_routing_spec.rb @@ -5,99 +5,99 @@ require 'rails_helper' describe 'API routes' do describe 'Credentials routes' do it 'routes to verify credentials' do - expect(get('/api/v1/accounts/verify_credentials')). - to route_to('api/v1/accounts/credentials#show') + expect(get('/api/v1/accounts/verify_credentials')) + .to route_to('api/v1/accounts/credentials#show') end it 'routes to update credentials' do - expect(patch('/api/v1/accounts/update_credentials')). - to route_to('api/v1/accounts/credentials#update') + expect(patch('/api/v1/accounts/update_credentials')) + .to route_to('api/v1/accounts/credentials#update') end end describe 'Account routes' do it 'routes to statuses' do - expect(get('/api/v1/accounts/user/statuses')). - to route_to('api/v1/accounts/statuses#index', account_id: 'user') + expect(get('/api/v1/accounts/user/statuses')) + .to route_to('api/v1/accounts/statuses#index', account_id: 'user') end it 'routes to followers' do - expect(get('/api/v1/accounts/user/followers')). - to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user') + expect(get('/api/v1/accounts/user/followers')) + .to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user') end it 'routes to following' do - expect(get('/api/v1/accounts/user/following')). - to route_to('api/v1/accounts/following_accounts#index', account_id: 'user') + expect(get('/api/v1/accounts/user/following')) + .to route_to('api/v1/accounts/following_accounts#index', account_id: 'user') end it 'routes to search' do - expect(get('/api/v1/accounts/search')). - to route_to('api/v1/accounts/search#show') + expect(get('/api/v1/accounts/search')) + .to route_to('api/v1/accounts/search#show') end it 'routes to relationships' do - expect(get('/api/v1/accounts/relationships')). - to route_to('api/v1/accounts/relationships#index') + expect(get('/api/v1/accounts/relationships')) + .to route_to('api/v1/accounts/relationships#index') end end describe 'Statuses routes' do it 'routes reblogged_by' do - expect(get('/api/v1/statuses/123/reblogged_by')). - to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123') + expect(get('/api/v1/statuses/123/reblogged_by')) + .to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123') end it 'routes favourited_by' do - expect(get('/api/v1/statuses/123/favourited_by')). - to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123') + expect(get('/api/v1/statuses/123/favourited_by')) + .to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123') end it 'routes reblog' do - expect(post('/api/v1/statuses/123/reblog')). - to route_to('api/v1/statuses/reblogs#create', status_id: '123') + expect(post('/api/v1/statuses/123/reblog')) + .to route_to('api/v1/statuses/reblogs#create', status_id: '123') end it 'routes unreblog' do - expect(post('/api/v1/statuses/123/unreblog')). - to route_to('api/v1/statuses/reblogs#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unreblog')) + .to route_to('api/v1/statuses/reblogs#destroy', status_id: '123') end it 'routes favourite' do - expect(post('/api/v1/statuses/123/favourite')). - to route_to('api/v1/statuses/favourites#create', status_id: '123') + expect(post('/api/v1/statuses/123/favourite')) + .to route_to('api/v1/statuses/favourites#create', status_id: '123') end it 'routes unfavourite' do - expect(post('/api/v1/statuses/123/unfavourite')). - to route_to('api/v1/statuses/favourites#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unfavourite')) + .to route_to('api/v1/statuses/favourites#destroy', status_id: '123') end it 'routes mute' do - expect(post('/api/v1/statuses/123/mute')). - to route_to('api/v1/statuses/mutes#create', status_id: '123') + expect(post('/api/v1/statuses/123/mute')) + .to route_to('api/v1/statuses/mutes#create', status_id: '123') end it 'routes unmute' do - expect(post('/api/v1/statuses/123/unmute')). - to route_to('api/v1/statuses/mutes#destroy', status_id: '123') + expect(post('/api/v1/statuses/123/unmute')) + .to route_to('api/v1/statuses/mutes#destroy', status_id: '123') end end describe 'Timeline routes' do it 'routes to home timeline' do - expect(get('/api/v1/timelines/home')). - to route_to('api/v1/timelines/home#show') + expect(get('/api/v1/timelines/home')) + .to route_to('api/v1/timelines/home#show') end it 'routes to public timeline' do - expect(get('/api/v1/timelines/public')). - to route_to('api/v1/timelines/public#show') + expect(get('/api/v1/timelines/public')) + .to route_to('api/v1/timelines/public#show') end it 'routes to tag timeline' do - expect(get('/api/v1/timelines/tag/test')). - to route_to('api/v1/timelines/tag#show', id: 'test') + expect(get('/api/v1/timelines/tag/test')) + .to route_to('api/v1/timelines/tag#show', id: 'test') end end end diff --git a/spec/routing/well_known_routes_spec.rb b/spec/routing/well_known_routes_spec.rb index 2e25605c2..03a562843 100644 --- a/spec/routing/well_known_routes_spec.rb +++ b/spec/routing/well_known_routes_spec.rb @@ -2,14 +2,14 @@ require 'rails_helper' describe 'the host-meta route' do it 'routes to correct place with xml format' do - expect(get('/.well-known/host-meta')). - to route_to('well_known/host_meta#show', format: 'xml') + expect(get('/.well-known/host-meta')) + .to route_to('well_known/host_meta#show', format: 'xml') end end describe 'the webfinger route' do it 'routes to correct place with json format' do - expect(get('/.well-known/webfinger')). - to route_to('well_known/webfinger#show') + expect(get('/.well-known/webfinger')) + .to route_to('well_known/webfinger#show') end end diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index 5b08d5aca..3bca06b73 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -5,7 +5,7 @@ require 'rails_helper' describe REST::AccountSerializer do let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } let(:user) { Fabricate(:user, role: role) } - let(:account) { user.account} + let(:account) { user.account } subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) } diff --git a/spec/services/account_statuses_cleanup_service_spec.rb b/spec/services/account_statuses_cleanup_service_spec.rb index 257655c41..a30e14ab6 100644 --- a/spec/services/account_statuses_cleanup_service_spec.rb +++ b/spec/services/account_statuses_cleanup_service_spec.rb @@ -42,8 +42,8 @@ describe AccountStatusesCleanupService, type: :service do context 'when called repeatedly with a budget of 2' do it 'reports 2 then 1 deleted statuses' do - expect(subject.call(account_policy, 2)).to eq 2 - expect(subject.call(account_policy, 2)).to eq 1 + expect(subject.call(account_policy, 2)).to eq 2 + expect(subject.call(account_policy, 2)).to eq 1 end it 'actually deletes the statuses in the expected order' do diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index a81dcad81..d6145c9b8 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -298,7 +298,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do first: { type: 'CollectionPage', partOf: "https://foo.bar/@foo/#{i}/replies", - items: ["https://foo.bar/@foo/#{i+1}"], + items: ["https://foo.bar/@foo/#{i + 1}"], }, }, attributedTo: ActivityPub::TagManager.instance.uri_for(sender), diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 2b20d17b1..40caa6eb0 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -172,10 +172,10 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do { type: 'Mention', href: "https://foo.test/users/#{i + 1}", - name: "@user#{i + 1 }", + name: "@user#{i + 1}", } ], - to: [ 'as:Public', "https://foo.test/users/#{i + 1}" ] + to: ['as:Public', "https://foo.test/users/#{i + 1}"] }.with_indifferent_access featured_json = { '@context': ['https://www.w3.org/ns/activitystreams'], diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index a308cede7..cb60e1cb8 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -95,11 +95,11 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do context 'when receiving a fabricated status' do let!(:actor) do Fabricate(:account, - username: 'bob', - domain: 'example.com', - uri: 'https://example.com/users/bob', - public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuuYyoyfsRkYnXRotMsId\nW3euBDDfiv9oVqOxUVC7bhel8KednIMrMCRWFAkgJhbrlzbIkjVr68o1MP9qLcn7\nCmH/BXHp7yhuFTr4byjdJKpwB+/i2jNEsvDH5jR8WTAeTCe0x/QHg21V3F7dSI5m\nCCZ/1dSIyOXLRTWVlfDlm3rE4ntlCo+US3/7oSWbg/4/4qEnt1HC32kvklgScxua\n4LR5ATdoXa5bFoopPWhul7MJ6NyWCyQyScUuGdlj8EN4kmKQJvphKHrI9fvhgOuG\nTvhTR1S5InA4azSSchY0tXEEw/VNxraeX0KPjbgr6DPcwhPd/m0nhVDq0zVyVBBD\nMwIDAQAB\n-----END PUBLIC KEY-----\n", - private_key: nil) + username: 'bob', + domain: 'example.com', + uri: 'https://example.com/users/bob', + public_key: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuuYyoyfsRkYnXRotMsId\nW3euBDDfiv9oVqOxUVC7bhel8KednIMrMCRWFAkgJhbrlzbIkjVr68o1MP9qLcn7\nCmH/BXHp7yhuFTr4byjdJKpwB+/i2jNEsvDH5jR8WTAeTCe0x/QHg21V3F7dSI5m\nCCZ/1dSIyOXLRTWVlfDlm3rE4ntlCo+US3/7oSWbg/4/4qEnt1HC32kvklgScxua\n4LR5ATdoXa5bFoopPWhul7MJ6NyWCyQyScUuGdlj8EN4kmKQJvphKHrI9fvhgOuG\nTvhTR1S5InA4azSSchY0tXEEw/VNxraeX0KPjbgr6DPcwhPd/m0nhVDq0zVyVBBD\nMwIDAQAB\n-----END PUBLIC KEY-----\n", + private_key: nil) end let(:payload) do @@ -107,7 +107,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do '@context': [ 'https://www.w3.org/ns/activitystreams', nil, - {'object': 'https://www.w3.org/ns/activitystreams#object'} + { 'object': 'https://www.w3.org/ns/activitystreams#object' } ], 'id': 'https://example.com/users/bob/fake-status/activity', 'type': 'Create', diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 750369d57..04292c507 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -104,20 +104,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end context 'when the status has not been explicitly edited and features a poll' do - let(:account) { Fabricate(:account, domain: 'example.com') } + let(:account) { Fabricate(:account, domain: 'example.com') } let!(:expiration) { 10.days.from_now.utc } let!(:status) do Fabricate(:status, - text: 'Hello world', - account: account, - poll_attributes: { - options: %w(Foo Bar), - account: account, - multiple: false, - hide_totals: false, - expires_at: expiration - } - ) + text: 'Hello world', + account: account, + poll_attributes: { + options: %w(Foo Bar), + account: account, + multiple: false, + hide_totals: false, + expires_at: expiration + }) end let(:payload) do @@ -156,20 +155,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do end context 'when the status changes a poll despite being not explicitly marked as updated' do - let(:account) { Fabricate(:account, domain: 'example.com') } + let(:account) { Fabricate(:account, domain: 'example.com') } let!(:expiration) { 10.days.from_now.utc } let!(:status) do Fabricate(:status, - text: 'Hello world', - account: account, - poll_attributes: { - options: %w(Foo Bar), - account: account, - multiple: false, - hide_totals: false, - expires_at: expiration - } - ) + text: 'Hello world', + account: account, + poll_attributes: { + options: %w(Foo Bar), + account: account, + multiple: false, + hide_totals: false, + expires_at: expiration + }) end let(:payload) do diff --git a/spec/services/bootstrap_timeline_service_spec.rb b/spec/services/bootstrap_timeline_service_spec.rb index 16f3e9962..149f6e6df 100644 --- a/spec/services/bootstrap_timeline_service_spec.rb +++ b/spec/services/bootstrap_timeline_service_spec.rb @@ -32,6 +32,5 @@ RSpec.describe BootstrapTimelineService, type: :service do expect(service).to_not have_received(:call) end end - end end diff --git a/spec/services/fetch_oembed_service_spec.rb b/spec/services/fetch_oembed_service_spec.rb index 88f0113ed..da2a8d0d1 100644 --- a/spec/services/fetch_oembed_service_spec.rb +++ b/spec/services/fetch_oembed_service_spec.rb @@ -151,7 +151,6 @@ describe FetchOEmbedService, type: :service do expect(subject.format).to eq :json end end - end context 'when endpoint is cached' do diff --git a/spec/services/import_service_spec.rb b/spec/services/import_service_spec.rb index e2d182920..217d0ee24 100644 --- a/spec/services/import_service_spec.rb +++ b/spec/services/import_service_spec.rb @@ -178,7 +178,7 @@ RSpec.describe ImportService, type: :service do context 'utf-8 encoded domains' do subject { ImportService.new } - let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') } + let!(:nare) { Fabricate(:account, username: 'nare', domain: 'թութ.հայ', locked: false, protocol: :activitypub, inbox_url: 'https://թութ.հայ/inbox') } # Make sure to not actually go to the remote server before do @@ -189,7 +189,7 @@ RSpec.describe ImportService, type: :service do let(:import) { Import.create(account: account, type: 'following', data: csv) } it 'follows the listed account' do - expect(account.follow_requests.count).to eq 0 + expect(account.follow_requests.count).to eq 0 subject.call(import) expect(account.follow_requests.count).to eq 1 end diff --git a/spec/services/remove_from_follwers_service_spec.rb b/spec/services/remove_from_follwers_service_spec.rb index a83f6f49a..9b9c846cf 100644 --- a/spec/services/remove_from_follwers_service_spec.rb +++ b/spec/services/remove_from_follwers_service_spec.rb @@ -7,7 +7,7 @@ RSpec.describe RemoveFromFollowersService, type: :service do describe 'local' do let(:sender) { Fabricate(:account, username: 'alice') } - + before do Follow.create(account: sender, target_account: bob) subject.call(bob, sender) diff --git a/spec/services/remove_status_service_spec.rb b/spec/services/remove_status_service_spec.rb index 482068d58..e253052f3 100644 --- a/spec/services/remove_status_service_spec.rb +++ b/spec/services/remove_status_service_spec.rb @@ -37,29 +37,29 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Delete activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Delete', - 'object' => { - 'type' => 'Tombstone', - 'id' => ActivityPub::TagManager.instance.uri_for(@status), - 'atomUri' => OStatus::TagManager.instance.uri_for(@status), - }, - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Delete', + 'object' => { + 'type' => 'Tombstone', + 'id' => ActivityPub::TagManager.instance.uri_for(@status), + 'atomUri' => OStatus::TagManager.instance.uri_for(@status), + }, + }) + )).to have_been_made.once end it 'sends Delete activity to rebloggers' do subject.call(@status) expect(a_request(:post, 'http://example2.com/inbox').with( - body: hash_including({ - 'type' => 'Delete', - 'object' => { - 'type' => 'Tombstone', - 'id' => ActivityPub::TagManager.instance.uri_for(@status), - 'atomUri' => OStatus::TagManager.instance.uri_for(@status), - }, - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Delete', + 'object' => { + 'type' => 'Tombstone', + 'id' => ActivityPub::TagManager.instance.uri_for(@status), + 'atomUri' => OStatus::TagManager.instance.uri_for(@status), + }, + }) + )).to have_been_made.once end it 'remove status from notifications' do @@ -78,14 +78,14 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Undo activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Undo', - 'object' => hash_including({ - 'type' => 'Announce', - 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), - }), - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Undo', + 'object' => hash_including({ + 'type' => 'Announce', + 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), + }), + }) + )).to have_been_made.once end end @@ -98,14 +98,14 @@ RSpec.describe RemoveStatusService, type: :service do it 'sends Undo activity to followers' do subject.call(@status) expect(a_request(:post, 'http://example.com/inbox').with( - body: hash_including({ - 'type' => 'Undo', - 'object' => hash_including({ - 'type' => 'Announce', - 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), - }), - }) - )).to have_been_made.once + body: hash_including({ + 'type' => 'Undo', + 'object' => hash_including({ + 'type' => 'Announce', + 'object' => ActivityPub::TagManager.instance.uri_for(@original_status), + }), + }) + )).to have_been_made.once end end end diff --git a/spec/services/resolve_account_service_spec.rb b/spec/services/resolve_account_service_spec.rb index 654606bea..1df30ea57 100644 --- a/spec/services/resolve_account_service_spec.rb +++ b/spec/services/resolve_account_service_spec.rb @@ -190,7 +190,7 @@ RSpec.describe ResolveAccountService, type: :service do context 'with an already-known acct: URI changing ActivityPub id' do let!(:old_account) { Fabricate(:account, username: 'foo', domain: 'ap.example.com', uri: 'https://old.example.com/users/foo', last_webfingered_at: nil) } - let!(:status) { Fabricate(:status, account: old_account, text: 'foo') } + let!(:status) { Fabricate(:status, account: old_account, text: 'foo') } it 'returns new remote account' do account = subject.call('foo@ap.example.com') diff --git a/spec/services/resolve_url_service_spec.rb b/spec/services/resolve_url_service_spec.rb index b3e3defbf..3598311ee 100644 --- a/spec/services/resolve_url_service_spec.rb +++ b/spec/services/resolve_url_service_spec.rb @@ -133,7 +133,7 @@ describe ResolveURLService, type: :service do let!(:status) { Fabricate(:status, account: poster, visibility: :public) } let(:url) { 'https://link.to/foobar' } let(:status_url) { ActivityPub::TagManager.instance.url_for(status) } - let(:uri) { ActivityPub::TagManager.instance.uri_for(status) } + let(:uri) { ActivityPub::TagManager.instance.uri_for(status) } before do stub_request(:get, url).to_return(status: 302, headers: { 'Location' => status_url }) diff --git a/spec/services/update_status_service_spec.rb b/spec/services/update_status_service_spec.rb index 16e981d2b..a7364ca8b 100644 --- a/spec/services/update_status_service_spec.rb +++ b/spec/services/update_status_service_spec.rb @@ -111,7 +111,7 @@ RSpec.describe UpdateStatusService, type: :service do context 'when poll changes' do let(:account) { Fabricate(:account) } - let!(:status) { Fabricate(:status, text: 'Foo', account: account, poll_attributes: {options: %w(Foo Bar), account: account, multiple: false, hide_totals: false, expires_at: 7.days.from_now }) } + let!(:status) { Fabricate(:status, text: 'Foo', account: account, poll_attributes: { options: %w(Foo Bar), account: account, multiple: false, hide_totals: false, expires_at: 7.days.from_now }) } let!(:poll) { status.poll } let!(:voter) { Fabricate(:account) } diff --git a/spec/support/stories/profile_stories.rb b/spec/support/stories/profile_stories.rb index 0c4a14d1c..de7ae17e6 100644 --- a/spec/support/stories/profile_stories.rb +++ b/spec/support/stories/profile_stories.rb @@ -20,8 +20,8 @@ module ProfileStories end def with_alice_as_local_user - @alice_bio = '@alice and @bob are fictional characters commonly used as'\ - 'placeholder names in #cryptology, as well as #science and'\ + @alice_bio = '@alice and @bob are fictional characters commonly used as' \ + 'placeholder names in #cryptology, as well as #science and' \ 'engineering 📖 literature. Not affiliated with @pepe.' @alice = Fabricate( diff --git a/spec/validators/note_length_validator_spec.rb b/spec/validators/note_length_validator_spec.rb index 6e9b4e132..390ac8d90 100644 --- a/spec/validators/note_length_validator_spec.rb +++ b/spec/validators/note_length_validator_spec.rb @@ -15,7 +15,7 @@ describe NoteLengthValidator do end it 'counts URLs as 23 characters flat' do - text = ('a' * 476) + " http://#{'b' * 30}.com/example" + text = ('a' * 476) + " http://#{'b' * 30}.com/example" account = double(note: text, errors: double(add: nil)) subject.validate_each(account, 'note', text) @@ -23,7 +23,7 @@ describe NoteLengthValidator do end it 'does not count non-autolinkable URLs as 23 characters flat' do - text = ('a' * 476) + "http://#{'b' * 30}.com/example" + text = ('a' * 476) + "http://#{'b' * 30}.com/example" account = double(note: text, errors: double(add: nil)) subject.validate_each(account, 'note', text) diff --git a/spec/validators/unreserved_username_validator_spec.rb b/spec/validators/unreserved_username_validator_spec.rb index 746b3866c..e2f051b08 100644 --- a/spec/validators/unreserved_username_validator_spec.rb +++ b/spec/validators/unreserved_username_validator_spec.rb @@ -11,10 +11,10 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do let(:validator) { described_class.new } let(:account) { double(username: username, errors: errors) } - let(:errors ) { double(add: nil) } + let(:errors) { double(add: nil) } context '@username.blank?' do - let(:username) { nil } + let(:username) { nil } it 'not calls errors.add' do expect(errors).not_to have_received(:add).with(:username, any_args) @@ -22,7 +22,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do end context '!@username.blank?' do - let(:username) { 'f' } + let(:username) { 'f' } context 'reserved_username?' do let(:reserved_username) { true } diff --git a/spec/workers/activitypub/distribution_worker_spec.rb b/spec/workers/activitypub/distribution_worker_spec.rb index 3a5900d9b..7f63e197b 100644 --- a/spec/workers/activitypub/distribution_worker_spec.rb +++ b/spec/workers/activitypub/distribution_worker_spec.rb @@ -34,7 +34,7 @@ describe ActivityPub::DistributionWorker do end context 'with direct status' do - let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox')} + let(:mentioned_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/inbox') } before do status.update(visibility: :direct) diff --git a/spec/workers/activitypub/move_distribution_worker_spec.rb b/spec/workers/activitypub/move_distribution_worker_spec.rb index af8c44cc0..57941065a 100644 --- a/spec/workers/activitypub/move_distribution_worker_spec.rb +++ b/spec/workers/activitypub/move_distribution_worker_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' describe ActivityPub::MoveDistributionWorker do subject { described_class.new } - let(:migration) { Fabricate(:account_migration) } + let(:migration) { Fabricate(:account_migration) } let(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com') } let(:blocker) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example2.com') } @@ -15,9 +15,9 @@ describe ActivityPub::MoveDistributionWorker do it 'delivers to followers and known blockers' do expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [ - [kind_of(String), migration.account.id, 'http://example.com'], - [kind_of(String), migration.account.id, 'http://example2.com'] - ]) + [kind_of(String), migration.account.id, 'http://example.com'], + [kind_of(String), migration.account.id, 'http://example2.com'] + ]) subject.perform(migration.id) end end diff --git a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb index 8f20725c8..8faf04836 100644 --- a/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb +++ b/spec/workers/scheduler/accounts_statuses_cleanup_scheduler_spec.rb @@ -82,7 +82,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do describe '#get_budget' do context 'on a single thread' do - let(:process_set_stub) { [ { 'concurrency' => 1, 'queues' => ['push', 'default'] } ] } + let(:process_set_stub) { [{ 'concurrency' => 1, 'queues' => ['push', 'default'] }] } it 'returns a low value' do expect(subject.compute_budget).to be < 10 -- 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/serializers/rest/account_serializer_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