Run rubocop formatting except line length (#23632)

shrike
Nick Schonning 2023-02-17 16:56:20 -05:00 committed by GitHub
parent 593bb8ce99
commit 669f6d2c0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 269 additions and 566 deletions

View File

@ -1,6 +1,6 @@
# This configuration was generated by # This configuration was generated by
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit` # `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 # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
@ -14,53 +14,6 @@ Bundler/OrderedGems:
Exclude: Exclude:
- 'Gemfile' - '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 # Offense count: 81
# This cop supports safe autocorrection (--autocorrect). # This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterGuardClause: Layout/EmptyLineAfterGuardClause:
@ -183,73 +136,6 @@ Layout/EmptyLineAfterMagicComment:
- 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb' - 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb'
- 'spec/models/tag_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 # Offense count: 113
# This cop supports safe autocorrection (--autocorrect). # This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
@ -276,49 +162,6 @@ Layout/HashAlignment:
- 'spec/models/admin/account_action_spec.rb' - 'spec/models/admin/account_action_spec.rb'
- 'spec/models/concerns/account_interactions_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 # Offense count: 577
# This cop supports safe autocorrection (--autocorrect). # This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
@ -326,124 +169,6 @@ Layout/LineContinuationSpacing:
Layout/LineLength: Layout/LineLength:
Enabled: false 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 # Offense count: 14
# Configuration parameters: AllowedMethods, AllowedPatterns. # Configuration parameters: AllowedMethods, AllowedPatterns.
Lint/AmbiguousBlockAssociation: Lint/AmbiguousBlockAssociation:

View File

@ -327,7 +327,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
def resolve_thread(status) def resolve_thread(status)
return unless status.reply? && status.thread.nil? && Request.valid_url?(in_reply_to_uri) 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 end
def fetch_replies(status) def fetch_replies(status)
@ -338,7 +338,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
return unless replies.nil? return unless replies.nil?
uri = value_or_id(collection) 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 end
def conversation_from_uri(uri) def conversation_from_uri(uri)

View File

@ -17,7 +17,7 @@ module Expireable
end end
def expires_in=(interval) 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 @expires_in = interval
end end

View File

@ -10,7 +10,7 @@ class ActivityPub::FetchRepliesService < BaseService
@items = collection_items(collection_or_uri) @items = collection_items(collection_or_uri)
return if @items.nil? 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 @items
end end

View File

@ -1,8 +1,8 @@
MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5 MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5
ActiveRecord::Migration[5.0] ActiveRecord::Migration[5.0]
else else
ActiveRecord::Migration[4.2] ActiveRecord::Migration[4.2]
end end
class RailsSettingsMigration < MIGRATION_BASE_CLASS class RailsSettingsMigration < MIGRATION_BASE_CLASS
def self.up 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.references :target, null: false, polymorphic: true, index: { name: 'index_settings_on_target_type_and_target_id' }
t.timestamps null: true t.timestamps null: true
end end
add_index :settings, [ :target_type, :target_id, :var ], unique: true add_index :settings, [:target_type, :target_id, :var], unique: true
end end
def self.down def self.down

View File

@ -4,9 +4,9 @@ class ImproveIndexOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecord::Mi
disable_ddl_transaction! disable_ddl_transaction!
def change def change
# These changes ware reverted by migration 20180514140000. # 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, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently
# add_index :statuses, [:account_id, :id], where: 'visibility = 3', 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 # remove_index :statuses, column: [:account_id, :id, :visibility, :updated_at], order: { id: :desc }, algorithm: :concurrently, name: :index_statuses_20180106
end end
end end

View File

@ -21,4 +21,3 @@ class AddLockVersionToPolls < ActiveRecord::Migration[5.2]
remove_column :polls, :lock_version remove_column :polls, :lock_version
end end
end end

View File

@ -4,4 +4,3 @@ class AddCommentsToDomainBlocks < ActiveRecord::Migration[5.2]
add_column :domain_blocks, :public_comment, :text add_column :domain_blocks, :public_comment, :text
end end
end end

View File

@ -3,4 +3,3 @@ class AddStatusIdsToAnnouncements < ActiveRecord::Migration[5.2]
add_column :announcements, :status_ids, :bigint, array: true add_column :announcements, :status_ids, :bigint, array: true
end end
end end

View File

@ -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) 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
end end

View File

@ -10,4 +10,3 @@ class CreateAccountNotes < ActiveRecord::Migration[5.2]
end end
end end
end end

View File

@ -17,4 +17,3 @@ class CreateAccountStatusesCleanupPolicies < ActiveRecord::Migration[6.1]
end end
end end
end end

View File

@ -5,7 +5,7 @@ class FixCustomFilterKeywordsIdSeq < ActiveRecord::Migration[6.1]
def up def up
# 20220613110711 manually inserts items with set `id` in the database, but # 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 safety_assured do
execute <<-SQL.squish execute <<-SQL.squish
BEGIN; BEGIN;

View File

@ -8,7 +8,7 @@ module Paperclip
# monkey-patch to avoid unlinking too avoid unlinking source file too early # monkey-patch to avoid unlinking too avoid unlinking source file too early
# see https://github.com/kreeti/kt-paperclip/issues/64 # 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? raise "Style #{name} has no processors defined." if style.processors.blank?
intermediate_files = [] intermediate_files = []
@ -16,16 +16,16 @@ module Paperclip
# if we're processing the original, close + unlink the source tempfile # if we're processing the original, close + unlink the source tempfile
intermediate_files << original if name == :original intermediate_files << original if name == :original
@queued_for_write[name] = style.processors. @queued_for_write[name] = style.processors
inject(original) do |file, processor| .inject(original) do |file, processor|
file = Paperclip.processor(processor).make(file, style.processor_options, self) file = Paperclip.processor(processor).make(file, style.processor_options, self)
intermediate_files << file unless file == original intermediate_files << file unless file == original
file file
end end
unadapted_file = @queued_for_write[name] unadapted_file = @queued_for_write[name]
@queued_for_write[name] = Paperclip.io_adapters. @queued_for_write[name] = Paperclip.io_adapters
for(@queued_for_write[name], @options[:adapter_options]) .for(@queued_for_write[name], @options[:adapter_options])
unadapted_file.close if unadapted_file.respond_to?(:close) unadapted_file.close if unadapted_file.respond_to?(:close)
@queued_for_write[name] @queued_for_write[name]
rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e rescue Paperclip::Errors::NotIdentifiedByImageMagickError => e

View File

@ -286,13 +286,13 @@ namespace :mastodon do
q.required true q.required true
q.modify :strip q.modify :strip
end 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| 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.required true
q.modify :strip q.modify :strip
end end
env['S3_ALIAS_HOST'] = "link.storjshare.io/raw/#{linksharing_access_key}/#{env['S3_BUCKET']}" env['S3_ALIAS_HOST'] = "link.storjshare.io/raw/#{linksharing_access_key}/#{env['S3_BUCKET']}"
when 'Google Cloud Storage' when 'Google Cloud Storage'
env['S3_ENABLED'] = 'true' env['S3_ENABLED'] = 'true'
env['S3_PROTOCOL'] = 'https' env['S3_PROTOCOL'] = 'https'

View File

@ -35,12 +35,12 @@ describe Rack::Attack do
let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } }
context 'for exact path' do context 'for exact path' do
let(:path) { '/auth' } let(:path) { '/auth' }
it_behaves_like 'throttled endpoint' it_behaves_like 'throttled endpoint'
end end
context 'for path with format' do context 'for path with format' do
let(:path) { '/auth.html' } let(:path) { '/auth.html' }
it_behaves_like 'throttled endpoint' it_behaves_like 'throttled endpoint'
end end
end end
@ -50,7 +50,7 @@ describe Rack::Attack do
let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } }
context 'for exact path' do context 'for exact path' do
let(:path) { '/api/v1/accounts' } let(:path) { '/api/v1/accounts' }
it_behaves_like 'throttled endpoint' it_behaves_like 'throttled endpoint'
end end
@ -70,12 +70,12 @@ describe Rack::Attack do
let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } } let(:request) { ->() { post path, {}, 'REMOTE_ADDR' => remote_ip } }
context 'for exact path' do context 'for exact path' do
let(:path) { '/auth/sign_in' } let(:path) { '/auth/sign_in' }
it_behaves_like 'throttled endpoint' it_behaves_like 'throttled endpoint'
end end
context 'for path with format' do context 'for path with format' do
let(:path) { '/auth/sign_in.html' } let(:path) { '/auth/sign_in.html' }
it_behaves_like 'throttled endpoint' it_behaves_like 'throttled endpoint'
end end
end end

View File

@ -8,10 +8,10 @@ describe Admin::DashboardController, type: :controller do
describe 'GET #index' do describe 'GET #index' do
before do before do
allow(Admin::SystemCheck).to receive(:perform).and_return([ allow(Admin::SystemCheck).to receive(:perform).and_return([
Admin::SystemCheck::Message.new(:database_schema_check), Admin::SystemCheck::Message.new(:database_schema_check),
Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path), Admin::SystemCheck::Message.new(:rules_check, nil, admin_rules_path),
Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'), Admin::SystemCheck::Message.new(:sidekiq_process_check, 'foo, bar'),
]) ])
sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin')) sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
end end

View File

@ -70,7 +70,7 @@ describe Api::V1::Accounts::CredentialsController do
it 'returns http success' do it 'returns http success' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end end
end end
describe 'with invalid data' do describe 'with invalid data' do
before do before do

View File

@ -20,7 +20,7 @@ RSpec.describe Api::V1::ReportsController, type: :controller do
let(:target_account) { status.account } let(:target_account) { status.account }
let(:category) { nil } let(:category) { nil }
let(:forward) { nil } let(:forward) { nil }
let(:rule_ids){ nil } let(:rule_ids) { nil }
before do before do
allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil)) allow(AdminMailer).to receive(:new_report).and_return(double('email', deliver_later: nil))

View File

@ -31,7 +31,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control
it 'returns accounts who favorited the status' do it 'returns accounts who favorited the status' do
get :index, params: { status_id: status.id, limit: 2 } get :index, params: { status_id: status.id, limit: 2 }
expect(body_as_json.size).to eq 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 end
it 'does not return blocked users' do it 'does not return blocked users' do

View File

@ -31,7 +31,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll
it 'returns accounts who reblogged the status' do it 'returns accounts who reblogged the status' do
get :index, params: { status_id: status.id, limit: 2 } get :index, params: { status_id: status.id, limit: 2 }
expect(body_as_json.size).to eq 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 end
it 'does not return blocked users' do it 'does not return blocked users' do

View File

@ -64,7 +64,7 @@ RSpec.describe Api::V2::Filters::StatusesController, type: :controller do
end end
describe 'GET #show' do describe 'GET #show' do
let(:scopes) { 'read:filters' } let(:scopes) { 'read:filters' }
let!(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) } let!(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) }
before do before do
@ -90,7 +90,7 @@ RSpec.describe Api::V2::Filters::StatusesController, type: :controller do
end end
describe 'DELETE #destroy' do describe 'DELETE #destroy' do
let(:scopes) { 'write:filters' } let(:scopes) { 'write:filters' }
let(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) } let(:status_filter) { Fabricate(:custom_filter_status, custom_filter: filter) }
before do before do

View File

@ -339,11 +339,11 @@ RSpec.describe Auth::SessionsController, type: :controller do
external_id: public_key_credential.id, external_id: public_key_credential.id,
public_key: public_key_credential.public_key, public_key: public_key_credential.public_key,
sign_count: '1000' sign_count: '1000'
) )
user.webauthn_credentials.take user.webauthn_credentials.take
end 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) } let(:fake_client) { WebAuthn::FakeClient.new(domain) }
@ -400,7 +400,7 @@ RSpec.describe Auth::SessionsController, type: :controller do
describe 'GET #webauthn_options' do describe 'GET #webauthn_options' do
context 'with WebAuthn and OTP enabled as second factor' 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) } let(:fake_client) { WebAuthn::FakeClient.new(domain) }

View File

@ -99,7 +99,6 @@ describe AuthorizeInteractionsController do
allow(ResolveAccountService).to receive(:new).and_return(service) allow(ResolveAccountService).to receive(:new).and_return(service)
allow(service).to receive(:call).with('user@hostname').and_return(target_account) allow(service).to receive(:call).with('user@hostname').and_return(target_account)
post :create, params: { acct: 'acct:user@hostname' } post :create, params: { acct: 'acct:user@hostname' }
expect(account.following?(target_account)).to be true expect(account.following?(target_account)).to be true

View File

@ -73,7 +73,7 @@ describe Settings::ApplicationsController do
name: 'My New App', name: 'My New App',
redirect_uri: 'urn:ietf:wg:oauth:2.0:oob', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
website: 'http://google.com', website: 'http://google.com',
scopes: [ 'read', 'write', 'follow' ] scopes: ['read', 'write', 'follow']
} }
} }
response response

View File

@ -5,7 +5,6 @@ require 'rails_helper'
describe Settings::TwoFactorAuthentication::ConfirmationsController do describe Settings::TwoFactorAuthentication::ConfirmationsController do
render_views render_views
shared_examples 'renders :new' do shared_examples 'renders :new' do
it 'renders the new view' do it 'renders the new view' do
subject subject

View File

@ -7,7 +7,7 @@ describe Settings::TwoFactorAuthentication::WebauthnCredentialsController do
render_views render_views
let(:user) { Fabricate(:user) } 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) } let(:fake_client) { WebAuthn::FakeClient.new(domain) }
def add_webauthn_credential(user) def add_webauthn_credential(user)

View File

@ -9,12 +9,12 @@ describe WellKnown::HostMetaController, type: :controller do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/xrd+xml' expect(response.media_type).to eq 'application/xrd+xml'
expect(response.body).to eq <<XML expect(response.body).to eq <<~XML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Link rel="lrdd" template="https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}"/> <Link rel="lrdd" template="https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}"/>
</XRD> </XRD>
XML XML
end end
end end
end end

View File

@ -1,4 +1,4 @@
Fabricator(:custom_filter_keyword) do Fabricator(:custom_filter_keyword) do
custom_filter custom_filter
keyword 'discourse' keyword 'discourse'
end end

View File

@ -3,4 +3,4 @@ Fabricator(:ip_block) do
severity "" severity ""
expires_at "2020-10-08 22:20:37" expires_at "2020-10-08 22:20:37"
comment "MyText" comment "MyText"
end end

View File

@ -1,5 +1,5 @@
Fabricator(:poll_vote) do Fabricator(:poll_vote) do
account account
poll poll
choice 0 choice 0
end end

View File

@ -4,4 +4,4 @@ Fabricator(:status_edit) do
text "MyText" text "MyText"
spoiler_text "MyText" spoiler_text "MyText"
media_attachments_changed false media_attachments_changed false
end end

View File

@ -1,3 +1,2 @@
Fabricator(:system_key) do Fabricator(:system_key) do
end end

View File

@ -408,7 +408,6 @@ RSpec.describe ActivityPub::Activity::Create do
end end
end end
context 'with media attachments with long description' do context 'with media attachments with long description' do
let(:object_json) do let(:object_json) do
{ {

View File

@ -20,7 +20,7 @@ describe Extractor do
text = '@screen_name' text = '@screen_name'
extracted = Extractor.extract_mentions_or_lists_with_indices(text) extracted = Extractor.extract_mentions_or_lists_with_indices(text)
expect(extracted).to eq [ expect(extracted).to eq [
{ screen_name: 'screen_name', indices: [ 0, 12 ] } { screen_name: 'screen_name', indices: [0, 12] }
] ]
end end
@ -44,19 +44,19 @@ describe Extractor do
it 'does not exclude normal hash text before ://' do it 'does not exclude normal hash text before ://' do
text = '#hashtag://' text = '#hashtag://'
extracted = Extractor.extract_hashtags_with_indices(text) 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 end
it 'excludes http://' do it 'excludes http://' do
text = '#hashtaghttp://' text = '#hashtaghttp://'
extracted = Extractor.extract_hashtags_with_indices(text) 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 end
it 'excludes https://' do it 'excludes https://' do
text = '#hashtaghttps://' text = '#hashtaghttps://'
extracted = Extractor.extract_hashtags_with_indices(text) 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 end
it 'yields hashtags if a block is given' do it 'yields hashtags if a block is given' do

View File

@ -4,7 +4,7 @@ require 'rails_helper'
describe FastIpMap do describe FastIpMap do
describe '#include?' 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 it 'returns true for an exact match' do
expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true expect(subject.include?(IPAddr.new('189.45.86.3'))).to be true

View File

@ -39,17 +39,17 @@ RSpec.describe LinkDetailsExtractor do
let(:original_url) { 'https://example.com/page.html' } let(:original_url) { 'https://example.com/page.html' }
context 'and is wrapped in CDATA tags' do context 'and is wrapped in CDATA tags' do
let(:html) { <<-HTML } let(:html) { <<~HTML }
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<script type="application/ld+json"> <script type="application/ld+json">
//<![CDATA[ //<![CDATA[
{"@context":"http://schema.org","@type":"NewsArticle","mainEntityOfPage":"https://example.com/page.html","headline":"Foo","datePublished":"2022-01-31T19:53:00+00:00","url":"https://example.com/page.html","description":"Bar","author":{"@type":"Person","name":"Hoge"},"publisher":{"@type":"Organization","name":"Baz"}} {"@context":"http://schema.org","@type":"NewsArticle","mainEntityOfPage":"https://example.com/page.html","headline":"Foo","datePublished":"2022-01-31T19:53:00+00:00","url":"https://example.com/page.html","description":"Bar","author":{"@type":"Person","name":"Hoge"},"publisher":{"@type":"Organization","name":"Baz"}}
//]]> //]]>
</script> </script>
</head> </head>
</html> </html>
HTML HTML
describe '#title' do describe '#title' do
@ -78,57 +78,57 @@ RSpec.describe LinkDetailsExtractor do
end end
context 'but the first tag is invalid JSON' do context 'but the first tag is invalid JSON' do
let(:html) { <<-HTML } let(:html) { <<~HTML }
<!doctype html> <!doctype html>
<html> <html>
<body> <body>
<script type="application/ld+json"> <script type="application/ld+json">
{ {
"@context":"https://schema.org", "@context":"https://schema.org",
"@type":"ItemList", "@type":"ItemList",
"url":"https://example.com/page.html", "url":"https://example.com/page.html",
"name":"Foo", "name":"Foo",
"description":"Bar" "description":"Bar"
}, },
{ {
"@context": "https://schema.org", "@context": "https://schema.org",
"@type": "BreadcrumbList", "@type": "BreadcrumbList",
"itemListElement":[ "itemListElement":[
{ {
"@type":"ListItem", "@type":"ListItem",
"position":1, "position":1,
"item":{ "item":{
"@id":"https://www.example.com", "@id":"https://www.example.com",
"name":"Baz" "name":"Baz"
} }
} }
] ]
} }
</script> </script>
<script type="application/ld+json"> <script type="application/ld+json">
{ {
"@context":"https://schema.org", "@context":"https://schema.org",
"@type":"NewsArticle", "@type":"NewsArticle",
"mainEntityOfPage": { "mainEntityOfPage": {
"@type":"WebPage", "@type":"WebPage",
"@id": "http://example.com/page.html" "@id": "http://example.com/page.html"
}, },
"headline": "Foo", "headline": "Foo",
"description": "Bar", "description": "Bar",
"datePublished": "2022-01-31T19:46:00+00:00", "datePublished": "2022-01-31T19:46:00+00:00",
"author": { "author": {
"@type": "Organization", "@type": "Organization",
"name": "Hoge" "name": "Hoge"
}, },
"publisher": { "publisher": {
"@type": "NewsMediaOrganization", "@type": "NewsMediaOrganization",
"name":"Baz", "name":"Baz",
"url":"https://example.com/" "url":"https://example.com/"
} }
} }
</script> </script>
</body> </body>
</html> </html>
HTML HTML
describe '#title' do describe '#title' do

View File

@ -97,7 +97,7 @@ RSpec.describe Account::Field, type: :model do
expect(subject.verifiable?).to be false expect(subject.verifiable?).to be false
end end
end end
context 'for text which is blank' do context 'for text which is blank' do
let(:value) { '' } let(:value) { '' }
@ -149,7 +149,7 @@ RSpec.describe Account::Field, type: :model do
expect(subject.verifiable?).to be false expect(subject.verifiable?).to be false
end end
end end
context 'for text which is blank' do context 'for text which is blank' do
let(:value) { '' } let(:value) { '' }

View File

@ -1,5 +1,4 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe AccountAlias, type: :model do RSpec.describe AccountAlias, type: :model do
end end

View File

@ -16,16 +16,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
context 'when widening a policy' do context 'when widening a policy' do
let!(:account_statuses_cleanup_policy) do let!(:account_statuses_cleanup_policy) do
Fabricate(:account_statuses_cleanup_policy, Fabricate(:account_statuses_cleanup_policy,
account: account, account: account,
keep_direct: true, keep_direct: true,
keep_pinned: true, keep_pinned: true,
keep_polls: true, keep_polls: true,
keep_media: true, keep_media: true,
keep_self_fav: true, keep_self_fav: true,
keep_self_bookmark: true, keep_self_bookmark: true,
min_favs: 1, min_favs: 1,
min_reblogs: 1 min_reblogs: 1)
)
end end
before do before do
@ -96,16 +95,15 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
context 'when narrowing a policy' do context 'when narrowing a policy' do
let!(:account_statuses_cleanup_policy) do let!(:account_statuses_cleanup_policy) do
Fabricate(:account_statuses_cleanup_policy, Fabricate(:account_statuses_cleanup_policy,
account: account, account: account,
keep_direct: false, keep_direct: false,
keep_pinned: false, keep_pinned: false,
keep_polls: false, keep_polls: false,
keep_media: false, keep_media: false,
keep_self_fav: false, keep_self_fav: false,
keep_self_bookmark: false, keep_self_bookmark: false,
min_favs: nil, min_favs: nil,
min_reblogs: nil min_reblogs: nil)
)
end end
it 'does not unnecessarily invalidate last_inspected' do it 'does not unnecessarily invalidate last_inspected' do
@ -232,7 +230,7 @@ RSpec.describe AccountStatusesCleanupPolicy, type: :model do
end end
describe '#compute_cutoff_id' do 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) } let(:account_statuses_cleanup_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
subject { account_statuses_cleanup_policy.compute_cutoff_id } subject { account_statuses_cleanup_policy.compute_cutoff_id }

View File

@ -400,7 +400,7 @@ describe AccountInteractions do
subject { account.domain_blocking?(domain) } subject { account.domain_blocking?(domain) }
context 'blocking the domain' do context 'blocking the domain' do
it' returns true' do it ' returns true' do
account_domain_block = Fabricate(:account_domain_block, domain: domain) account_domain_block = Fabricate(:account_domain_block, domain: domain)
account.domain_blocks << account_domain_block account.domain_blocks << account_domain_block
is_expected.to be true is_expected.to be true

View File

@ -1,5 +1,4 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Device, type: :model do RSpec.describe Device, type: :model do
end end

View File

@ -1,5 +1,4 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe EncryptedMessage, type: :model do RSpec.describe EncryptedMessage, type: :model do
end end

View File

@ -3,7 +3,7 @@ require 'rails_helper'
describe Export do describe Export do
let(:account) { Fabricate(:account) } let(:account) { Fabricate(:account) }
let(:target_accounts) do 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 end
describe 'to_csv' do describe 'to_csv' do

View File

@ -1,5 +1,4 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe LoginActivity, type: :model do RSpec.describe LoginActivity, type: :model do
end end

View File

@ -1,5 +1,4 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe OneTimeKey, type: :model do RSpec.describe OneTimeKey, type: :model do
end end

View File

@ -1,5 +1,4 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe SystemKey, type: :model do RSpec.describe SystemKey, type: :model do
end end

View File

@ -76,7 +76,7 @@ RSpec.describe Trends::Statuses do
before do before do
13.times { reblog(status1, today) } 13.times { reblog(status1, today) }
13.times { reblog(status2, today) } 13.times { reblog(status2, today) }
4.times { reblog(status3, today) } 4.times { reblog(status3, today) }
end end
context do context do

View File

@ -58,7 +58,7 @@ RSpec.describe UserRole, type: :model do
end end
describe '#permissions_as_keys=' do describe '#permissions_as_keys=' do
let(:input) { } let(:input) {}
before do before do
subject.permissions_as_keys = input subject.permissions_as_keys = input

View File

@ -5,99 +5,99 @@ require 'rails_helper'
describe 'API routes' do describe 'API routes' do
describe 'Credentials routes' do describe 'Credentials routes' do
it 'routes to verify credentials' do it 'routes to verify credentials' do
expect(get('/api/v1/accounts/verify_credentials')). expect(get('/api/v1/accounts/verify_credentials'))
to route_to('api/v1/accounts/credentials#show') .to route_to('api/v1/accounts/credentials#show')
end end
it 'routes to update credentials' do it 'routes to update credentials' do
expect(patch('/api/v1/accounts/update_credentials')). expect(patch('/api/v1/accounts/update_credentials'))
to route_to('api/v1/accounts/credentials#update') .to route_to('api/v1/accounts/credentials#update')
end end
end end
describe 'Account routes' do describe 'Account routes' do
it 'routes to statuses' do it 'routes to statuses' do
expect(get('/api/v1/accounts/user/statuses')). expect(get('/api/v1/accounts/user/statuses'))
to route_to('api/v1/accounts/statuses#index', account_id: 'user') .to route_to('api/v1/accounts/statuses#index', account_id: 'user')
end end
it 'routes to followers' do it 'routes to followers' do
expect(get('/api/v1/accounts/user/followers')). expect(get('/api/v1/accounts/user/followers'))
to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user') .to route_to('api/v1/accounts/follower_accounts#index', account_id: 'user')
end end
it 'routes to following' do it 'routes to following' do
expect(get('/api/v1/accounts/user/following')). expect(get('/api/v1/accounts/user/following'))
to route_to('api/v1/accounts/following_accounts#index', account_id: 'user') .to route_to('api/v1/accounts/following_accounts#index', account_id: 'user')
end end
it 'routes to search' do it 'routes to search' do
expect(get('/api/v1/accounts/search')). expect(get('/api/v1/accounts/search'))
to route_to('api/v1/accounts/search#show') .to route_to('api/v1/accounts/search#show')
end end
it 'routes to relationships' do it 'routes to relationships' do
expect(get('/api/v1/accounts/relationships')). expect(get('/api/v1/accounts/relationships'))
to route_to('api/v1/accounts/relationships#index') .to route_to('api/v1/accounts/relationships#index')
end end
end end
describe 'Statuses routes' do describe 'Statuses routes' do
it 'routes reblogged_by' do it 'routes reblogged_by' do
expect(get('/api/v1/statuses/123/reblogged_by')). expect(get('/api/v1/statuses/123/reblogged_by'))
to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123') .to route_to('api/v1/statuses/reblogged_by_accounts#index', status_id: '123')
end end
it 'routes favourited_by' do it 'routes favourited_by' do
expect(get('/api/v1/statuses/123/favourited_by')). expect(get('/api/v1/statuses/123/favourited_by'))
to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123') .to route_to('api/v1/statuses/favourited_by_accounts#index', status_id: '123')
end end
it 'routes reblog' do it 'routes reblog' do
expect(post('/api/v1/statuses/123/reblog')). expect(post('/api/v1/statuses/123/reblog'))
to route_to('api/v1/statuses/reblogs#create', status_id: '123') .to route_to('api/v1/statuses/reblogs#create', status_id: '123')
end end
it 'routes unreblog' do it 'routes unreblog' do
expect(post('/api/v1/statuses/123/unreblog')). expect(post('/api/v1/statuses/123/unreblog'))
to route_to('api/v1/statuses/reblogs#destroy', status_id: '123') .to route_to('api/v1/statuses/reblogs#destroy', status_id: '123')
end end
it 'routes favourite' do it 'routes favourite' do
expect(post('/api/v1/statuses/123/favourite')). expect(post('/api/v1/statuses/123/favourite'))
to route_to('api/v1/statuses/favourites#create', status_id: '123') .to route_to('api/v1/statuses/favourites#create', status_id: '123')
end end
it 'routes unfavourite' do it 'routes unfavourite' do
expect(post('/api/v1/statuses/123/unfavourite')). expect(post('/api/v1/statuses/123/unfavourite'))
to route_to('api/v1/statuses/favourites#destroy', status_id: '123') .to route_to('api/v1/statuses/favourites#destroy', status_id: '123')
end end
it 'routes mute' do it 'routes mute' do
expect(post('/api/v1/statuses/123/mute')). expect(post('/api/v1/statuses/123/mute'))
to route_to('api/v1/statuses/mutes#create', status_id: '123') .to route_to('api/v1/statuses/mutes#create', status_id: '123')
end end
it 'routes unmute' do it 'routes unmute' do
expect(post('/api/v1/statuses/123/unmute')). expect(post('/api/v1/statuses/123/unmute'))
to route_to('api/v1/statuses/mutes#destroy', status_id: '123') .to route_to('api/v1/statuses/mutes#destroy', status_id: '123')
end end
end end
describe 'Timeline routes' do describe 'Timeline routes' do
it 'routes to home timeline' do it 'routes to home timeline' do
expect(get('/api/v1/timelines/home')). expect(get('/api/v1/timelines/home'))
to route_to('api/v1/timelines/home#show') .to route_to('api/v1/timelines/home#show')
end end
it 'routes to public timeline' do it 'routes to public timeline' do
expect(get('/api/v1/timelines/public')). expect(get('/api/v1/timelines/public'))
to route_to('api/v1/timelines/public#show') .to route_to('api/v1/timelines/public#show')
end end
it 'routes to tag timeline' do it 'routes to tag timeline' do
expect(get('/api/v1/timelines/tag/test')). expect(get('/api/v1/timelines/tag/test'))
to route_to('api/v1/timelines/tag#show', id: 'test') .to route_to('api/v1/timelines/tag#show', id: 'test')
end end
end end
end end

View File

@ -2,14 +2,14 @@ require 'rails_helper'
describe 'the host-meta route' do describe 'the host-meta route' do
it 'routes to correct place with xml format' do it 'routes to correct place with xml format' do
expect(get('/.well-known/host-meta')). expect(get('/.well-known/host-meta'))
to route_to('well_known/host_meta#show', format: 'xml') .to route_to('well_known/host_meta#show', format: 'xml')
end end
end end
describe 'the webfinger route' do describe 'the webfinger route' do
it 'routes to correct place with json format' do it 'routes to correct place with json format' do
expect(get('/.well-known/webfinger')). expect(get('/.well-known/webfinger'))
to route_to('well_known/webfinger#show') .to route_to('well_known/webfinger#show')
end end
end end

View File

@ -5,7 +5,7 @@ require 'rails_helper'
describe REST::AccountSerializer do describe REST::AccountSerializer do
let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) }
let(:user) { Fabricate(:user, role: role) } 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) } subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) }

View File

@ -42,8 +42,8 @@ describe AccountStatusesCleanupService, type: :service do
context 'when called repeatedly with a budget of 2' do context 'when called repeatedly with a budget of 2' do
it 'reports 2 then 1 deleted statuses' 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 2
expect(subject.call(account_policy, 2)).to eq 1 expect(subject.call(account_policy, 2)).to eq 1
end end
it 'actually deletes the statuses in the expected order' do it 'actually deletes the statuses in the expected order' do

View File

@ -298,7 +298,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
first: { first: {
type: 'CollectionPage', type: 'CollectionPage',
partOf: "https://foo.bar/@foo/#{i}/replies", 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), attributedTo: ActivityPub::TagManager.instance.uri_for(sender),

View File

@ -172,10 +172,10 @@ RSpec.describe ActivityPub::ProcessAccountService, type: :service do
{ {
type: 'Mention', type: 'Mention',
href: "https://foo.test/users/#{i + 1}", 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 }.with_indifferent_access
featured_json = { featured_json = {
'@context': ['https://www.w3.org/ns/activitystreams'], '@context': ['https://www.w3.org/ns/activitystreams'],

View File

@ -95,11 +95,11 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
context 'when receiving a fabricated status' do context 'when receiving a fabricated status' do
let!(:actor) do let!(:actor) do
Fabricate(:account, Fabricate(:account,
username: 'bob', username: 'bob',
domain: 'example.com', domain: 'example.com',
uri: 'https://example.com/users/bob', 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", 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) private_key: nil)
end end
let(:payload) do let(:payload) do
@ -107,7 +107,7 @@ RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
'@context': [ '@context': [
'https://www.w3.org/ns/activitystreams', 'https://www.w3.org/ns/activitystreams',
nil, 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', 'id': 'https://example.com/users/bob/fake-status/activity',
'type': 'Create', 'type': 'Create',

View File

@ -104,20 +104,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
end end
context 'when the status has not been explicitly edited and features a poll' do 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!(:expiration) { 10.days.from_now.utc }
let!(:status) do let!(:status) do
Fabricate(:status, Fabricate(:status,
text: 'Hello world', text: 'Hello world',
account: account, account: account,
poll_attributes: { poll_attributes: {
options: %w(Foo Bar), options: %w(Foo Bar),
account: account, account: account,
multiple: false, multiple: false,
hide_totals: false, hide_totals: false,
expires_at: expiration expires_at: expiration
} })
)
end end
let(:payload) do let(:payload) do
@ -156,20 +155,19 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
end end
context 'when the status changes a poll despite being not explicitly marked as updated' do 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!(:expiration) { 10.days.from_now.utc }
let!(:status) do let!(:status) do
Fabricate(:status, Fabricate(:status,
text: 'Hello world', text: 'Hello world',
account: account, account: account,
poll_attributes: { poll_attributes: {
options: %w(Foo Bar), options: %w(Foo Bar),
account: account, account: account,
multiple: false, multiple: false,
hide_totals: false, hide_totals: false,
expires_at: expiration expires_at: expiration
} })
)
end end
let(:payload) do let(:payload) do

View File

@ -32,6 +32,5 @@ RSpec.describe BootstrapTimelineService, type: :service do
expect(service).to_not have_received(:call) expect(service).to_not have_received(:call)
end end
end end
end end
end end

View File

@ -151,7 +151,6 @@ describe FetchOEmbedService, type: :service do
expect(subject.format).to eq :json expect(subject.format).to eq :json
end end
end end
end end
context 'when endpoint is cached' do context 'when endpoint is cached' do

View File

@ -178,7 +178,7 @@ RSpec.describe ImportService, type: :service do
context 'utf-8 encoded domains' do context 'utf-8 encoded domains' do
subject { ImportService.new } 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 # Make sure to not actually go to the remote server
before do before do
@ -189,7 +189,7 @@ RSpec.describe ImportService, type: :service do
let(:import) { Import.create(account: account, type: 'following', data: csv) } let(:import) { Import.create(account: account, type: 'following', data: csv) }
it 'follows the listed account' do 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) subject.call(import)
expect(account.follow_requests.count).to eq 1 expect(account.follow_requests.count).to eq 1
end end

View File

@ -7,7 +7,7 @@ RSpec.describe RemoveFromFollowersService, type: :service do
describe 'local' do describe 'local' do
let(:sender) { Fabricate(:account, username: 'alice') } let(:sender) { Fabricate(:account, username: 'alice') }
before do before do
Follow.create(account: sender, target_account: bob) Follow.create(account: sender, target_account: bob)
subject.call(bob, sender) subject.call(bob, sender)

View File

@ -37,29 +37,29 @@ RSpec.describe RemoveStatusService, type: :service do
it 'sends Delete activity to followers' do it 'sends Delete activity to followers' do
subject.call(@status) subject.call(@status)
expect(a_request(:post, 'http://example.com/inbox').with( expect(a_request(:post, 'http://example.com/inbox').with(
body: hash_including({ body: hash_including({
'type' => 'Delete', 'type' => 'Delete',
'object' => { 'object' => {
'type' => 'Tombstone', 'type' => 'Tombstone',
'id' => ActivityPub::TagManager.instance.uri_for(@status), 'id' => ActivityPub::TagManager.instance.uri_for(@status),
'atomUri' => OStatus::TagManager.instance.uri_for(@status), 'atomUri' => OStatus::TagManager.instance.uri_for(@status),
}, },
}) })
)).to have_been_made.once )).to have_been_made.once
end end
it 'sends Delete activity to rebloggers' do it 'sends Delete activity to rebloggers' do
subject.call(@status) subject.call(@status)
expect(a_request(:post, 'http://example2.com/inbox').with( expect(a_request(:post, 'http://example2.com/inbox').with(
body: hash_including({ body: hash_including({
'type' => 'Delete', 'type' => 'Delete',
'object' => { 'object' => {
'type' => 'Tombstone', 'type' => 'Tombstone',
'id' => ActivityPub::TagManager.instance.uri_for(@status), 'id' => ActivityPub::TagManager.instance.uri_for(@status),
'atomUri' => OStatus::TagManager.instance.uri_for(@status), 'atomUri' => OStatus::TagManager.instance.uri_for(@status),
}, },
}) })
)).to have_been_made.once )).to have_been_made.once
end end
it 'remove status from notifications' do it 'remove status from notifications' do
@ -78,14 +78,14 @@ RSpec.describe RemoveStatusService, type: :service do
it 'sends Undo activity to followers' do it 'sends Undo activity to followers' do
subject.call(@status) subject.call(@status)
expect(a_request(:post, 'http://example.com/inbox').with( expect(a_request(:post, 'http://example.com/inbox').with(
body: hash_including({ body: hash_including({
'type' => 'Undo', 'type' => 'Undo',
'object' => hash_including({ 'object' => hash_including({
'type' => 'Announce', 'type' => 'Announce',
'object' => ActivityPub::TagManager.instance.uri_for(@original_status), 'object' => ActivityPub::TagManager.instance.uri_for(@original_status),
}), }),
}) })
)).to have_been_made.once )).to have_been_made.once
end end
end end
@ -98,14 +98,14 @@ RSpec.describe RemoveStatusService, type: :service do
it 'sends Undo activity to followers' do it 'sends Undo activity to followers' do
subject.call(@status) subject.call(@status)
expect(a_request(:post, 'http://example.com/inbox').with( expect(a_request(:post, 'http://example.com/inbox').with(
body: hash_including({ body: hash_including({
'type' => 'Undo', 'type' => 'Undo',
'object' => hash_including({ 'object' => hash_including({
'type' => 'Announce', 'type' => 'Announce',
'object' => ActivityPub::TagManager.instance.uri_for(@original_status), 'object' => ActivityPub::TagManager.instance.uri_for(@original_status),
}), }),
}) })
)).to have_been_made.once )).to have_been_made.once
end end
end end
end end

View File

@ -190,7 +190,7 @@ RSpec.describe ResolveAccountService, type: :service do
context 'with an already-known acct: URI changing ActivityPub id' 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!(: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 it 'returns new remote account' do
account = subject.call('foo@ap.example.com') account = subject.call('foo@ap.example.com')

View File

@ -133,7 +133,7 @@ describe ResolveURLService, type: :service do
let!(:status) { Fabricate(:status, account: poster, visibility: :public) } let!(:status) { Fabricate(:status, account: poster, visibility: :public) }
let(:url) { 'https://link.to/foobar' } let(:url) { 'https://link.to/foobar' }
let(:status_url) { ActivityPub::TagManager.instance.url_for(status) } 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 before do
stub_request(:get, url).to_return(status: 302, headers: { 'Location' => status_url }) stub_request(:get, url).to_return(status: 302, headers: { 'Location' => status_url })

View File

@ -111,7 +111,7 @@ RSpec.describe UpdateStatusService, type: :service do
context 'when poll changes' do context 'when poll changes' do
let(:account) { Fabricate(:account) } 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!(:poll) { status.poll }
let!(:voter) { Fabricate(:account) } let!(:voter) { Fabricate(:account) }

View File

@ -20,8 +20,8 @@ module ProfileStories
end end
def with_alice_as_local_user def with_alice_as_local_user
@alice_bio = '@alice and @bob are fictional characters commonly used as'\ @alice_bio = '@alice and @bob are fictional characters commonly used as' \
'placeholder names in #cryptology, as well as #science and'\ 'placeholder names in #cryptology, as well as #science and' \
'engineering 📖 literature. Not affiliated with @pepe.' 'engineering 📖 literature. Not affiliated with @pepe.'
@alice = Fabricate( @alice = Fabricate(

View File

@ -15,7 +15,7 @@ describe NoteLengthValidator do
end end
it 'counts URLs as 23 characters flat' do 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)) account = double(note: text, errors: double(add: nil))
subject.validate_each(account, 'note', text) subject.validate_each(account, 'note', text)
@ -23,7 +23,7 @@ describe NoteLengthValidator do
end end
it 'does not count non-autolinkable URLs as 23 characters flat' do 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)) account = double(note: text, errors: double(add: nil))
subject.validate_each(account, 'note', text) subject.validate_each(account, 'note', text)

View File

@ -11,10 +11,10 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do
let(:validator) { described_class.new } let(:validator) { described_class.new }
let(:account) { double(username: username, errors: errors) } let(:account) { double(username: username, errors: errors) }
let(:errors ) { double(add: nil) } let(:errors) { double(add: nil) }
context '@username.blank?' do context '@username.blank?' do
let(:username) { nil } let(:username) { nil }
it 'not calls errors.add' do it 'not calls errors.add' do
expect(errors).not_to have_received(:add).with(:username, any_args) expect(errors).not_to have_received(:add).with(:username, any_args)
@ -22,7 +22,7 @@ RSpec.describe UnreservedUsernameValidator, type: :validator do
end end
context '!@username.blank?' do context '!@username.blank?' do
let(:username) { 'f' } let(:username) { 'f' }
context 'reserved_username?' do context 'reserved_username?' do
let(:reserved_username) { true } let(:reserved_username) { true }

View File

@ -34,7 +34,7 @@ describe ActivityPub::DistributionWorker do
end end
context 'with direct status' do 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 before do
status.update(visibility: :direct) status.update(visibility: :direct)

View File

@ -3,7 +3,7 @@ require 'rails_helper'
describe ActivityPub::MoveDistributionWorker do describe ActivityPub::MoveDistributionWorker do
subject { described_class.new } 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(:follower) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example.com') }
let(:blocker) { Fabricate(:account, protocol: :activitypub, inbox_url: 'http://example2.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 it 'delivers to followers and known blockers' do
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [ expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [
[kind_of(String), migration.account.id, 'http://example.com'], [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://example2.com']
]) ])
subject.perform(migration.id) subject.perform(migration.id)
end end
end end

View File

@ -82,7 +82,7 @@ describe Scheduler::AccountsStatusesCleanupScheduler do
describe '#get_budget' do describe '#get_budget' do
context 'on a single thread' 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 it 'returns a low value' do
expect(subject.compute_budget).to be < 10 expect(subject.compute_budget).to be < 10