Merge remote-tracking branch 'parent/main' into upstream-20240319

This commit is contained in:
KMY 2024-03-19 09:15:20 +09:00
commit 76598bd542
496 changed files with 5795 additions and 3709 deletions

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe AccountSearchService, type: :service do
describe AccountSearchService do
describe '#call' do
context 'with a query to ignore' do
it 'returns empty array for missing query' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe AccountStatusesCleanupService, type: :service do
describe AccountStatusesCleanupService do
let(:account) { Fabricate(:account, username: 'alice', domain: nil) }
let(:account_policy) { Fabricate(:account_statuses_cleanup_policy, account: account) }
let!(:unrelated_status) { Fabricate(:status, created_at: 3.years.ago) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchFeaturedCollectionService, type: :service do
RSpec.describe ActivityPub::FetchFeaturedCollectionService 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') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service do
RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService do
subject { described_class.new }
let(:collection_url) { 'https://example.com/account/tags' }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
RSpec.describe ActivityPub::FetchRemoteAccountService do
subject { described_class.new }
let!(:actor) do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchRemoteActorService, type: :service do
RSpec.describe ActivityPub::FetchRemoteActorService do
subject { described_class.new }
let!(:actor) do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchRemoteKeyService, type: :service do
RSpec.describe ActivityPub::FetchRemoteKeyService do
subject { described_class.new }
let(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice' }] } }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
RSpec.describe ActivityPub::FetchRemoteStatusService do
include ActionView::Helpers::TextHelper
subject { described_class.new }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchRepliesService, type: :service do
RSpec.describe ActivityPub::FetchRepliesService do
subject { described_class.new }
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::ProcessAccountService, type: :service do
RSpec.describe ActivityPub::ProcessAccountService do
subject { described_class.new }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
RSpec.describe ActivityPub::ProcessCollectionService do
subject { described_class.new }
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }

View file

@ -6,7 +6,7 @@ def poll_option_json(name, votes)
{ type: 'Note', name: name, replies: { type: 'Collection', totalItems: votes } }
end
RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
RSpec.describe ActivityPub::ProcessStatusUpdateService do
subject { described_class.new }
let(:thread) { nil }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ActivityPub::SynchronizeFollowersService, type: :service do
RSpec.describe ActivityPub::SynchronizeFollowersService do
subject { described_class.new }
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account', inbox_url: 'http://example.com/inbox') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe AfterBlockDomainFromAccountService, type: :service do
RSpec.describe AfterBlockDomainFromAccountService do
subject { described_class.new }
let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org', inbox_url: 'https://evil.org/inbox', protocol: :activitypub) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe AfterBlockService, type: :service do
RSpec.describe AfterBlockService do
subject { described_class.new.call(account, target_account) }
let(:account) { Fabricate(:account) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe AppSignUpService, type: :service do
RSpec.describe AppSignUpService do
subject { described_class.new }
let(:app) { Fabricate(:application, scopes: 'read write') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe AuthorizeFollowService, type: :service do
RSpec.describe AuthorizeFollowService do
subject { described_class.new }
let(:sender) { Fabricate(:account, username: 'alice') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe BackupService, type: :service do
RSpec.describe BackupService do
subject(:service_call) { described_class.new.call(backup) }
let!(:user) { Fabricate(:user) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe BatchedRemoveStatusService, :sidekiq_inline, type: :service do
RSpec.describe BatchedRemoveStatusService, :sidekiq_inline do
subject { described_class.new }
let!(:alice) { Fabricate(:account) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe BlockDomainService, type: :service do
RSpec.describe BlockDomainService do
subject { described_class.new }
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe BlockService, type: :service do
RSpec.describe BlockService do
subject { described_class.new }
let(:sender) { Fabricate(:account, username: 'alice') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe BootstrapTimelineService, type: :service do
RSpec.describe BootstrapTimelineService do
subject { described_class.new }
context 'when the new user has registered from an invite' do

View file

@ -110,7 +110,7 @@ RSpec.describe BulkImportRowService do
end
it 'adds the target account to the list' do
expect { subject.call(import_row) }.to change { ListAccount.joins(:list).exists?(account_id: target_account.id, list: { title: 'my list' }) }.from(false).to(true)
expect { subject.call(import_row) }.to add_target_account_to_list
end
end
@ -124,7 +124,7 @@ RSpec.describe BulkImportRowService do
end
it 'adds the target account to the list' do
expect { subject.call(import_row) }.to change { ListAccount.joins(:list).exists?(account_id: target_account.id, list: { title: 'my list' }) }.from(false).to(true)
expect { subject.call(import_row) }.to add_target_account_to_list
end
end
@ -134,7 +134,7 @@ RSpec.describe BulkImportRowService do
end
it 'adds the target account to the list' do
expect { subject.call(import_row) }.to change { ListAccount.joins(:list).exists?(account_id: target_account.id, list: { title: 'my list' }) }.from(false).to(true)
expect { subject.call(import_row) }.to add_target_account_to_list
end
end
@ -146,9 +146,24 @@ RSpec.describe BulkImportRowService do
end
it 'adds the target account to the list' do
expect { subject.call(import_row) }.to change { ListAccount.joins(:list).exists?(account_id: target_account.id, list: { title: 'my list' }) }.from(false).to(true)
expect { subject.call(import_row) }.to add_target_account_to_list
end
end
def add_target_account_to_list
change { target_account_on_list? }
.from(false)
.to(true)
end
def target_account_on_list?
ListAccount
.joins(:list)
.exists?(
account_id: target_account.id,
list: { title: 'my list' }
)
end
end
context 'when the list does not exist yet' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ClearDomainMediaService, type: :service do
RSpec.describe ClearDomainMediaService do
subject { described_class.new }
let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe DeleteAccountService, type: :service do
RSpec.describe DeleteAccountService do
shared_examples 'common behavior' do
subject { described_class.new.call(account) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe FanOutOnWriteService, type: :service do
RSpec.describe FanOutOnWriteService do
subject { described_class.new }
let(:ltl_enabled) { true }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe FavouriteService, type: :service do
RSpec.describe FavouriteService do
subject { described_class.new }
let(:sender) { Fabricate(:account, username: 'alice') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe FetchLinkCardService, type: :service do
RSpec.describe FetchLinkCardService do
subject { described_class.new }
let(:html) { '<!doctype html><title>Hello world</title>' }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe FetchOEmbedService, type: :service do
describe FetchOEmbedService do
subject { described_class.new }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe FetchRemoteStatusService, type: :service do
RSpec.describe FetchRemoteStatusService do
let(:account) { Fabricate(:account, domain: 'example.org', uri: 'https://example.org/foo') }
let(:prefetched_body) { nil }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe FetchResourceService, type: :service do
RSpec.describe FetchResourceService do
describe '#call' do
subject { described_class.new.call(url) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe FollowService, type: :service do
RSpec.describe FollowService do
subject { described_class.new }
let(:sender) { Fabricate(:account, username: 'alice') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ImportService, :sidekiq_inline, type: :service do
RSpec.describe ImportService, :sidekiq_inline do
include RoutingHelper
let!(:account) { Fabricate(:account, locked: false) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe MuteService, type: :service do
RSpec.describe MuteService do
subject { described_class.new.call(account, target_account) }
let(:account) { Fabricate(:account) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe NotifyService, type: :service do
RSpec.describe NotifyService do
subject { described_class.new.call(recipient, type, activity) }
let(:user) { Fabricate(:user) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe PostStatusService, type: :service do
RSpec.describe PostStatusService do
subject { described_class.new }
it 'creates a new status' do
@ -481,7 +481,7 @@ RSpec.describe PostStatusService, type: :service do
expect do
subject.call(account, text: '@alice hm, @bob is really annoying lately', allowed_mentions: [mentioned_account.id])
end.to raise_error(an_instance_of(PostStatusService::UnexpectedMentionsError).and(having_attributes(accounts: [unexpected_mentioned_account])))
end.to raise_error(an_instance_of(described_class::UnexpectedMentionsError).and(having_attributes(accounts: [unexpected_mentioned_account])))
end
it 'processes duplicate mentions correctly' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe PrecomputeFeedService, type: :service do
RSpec.describe PrecomputeFeedService do
subject { described_class.new }
describe 'call' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ProcessMentionsService, type: :service do
RSpec.describe ProcessMentionsService do
subject { described_class.new }
let(:account) { Fabricate(:account, username: 'alice') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe PurgeDomainService, type: :service do
RSpec.describe PurgeDomainService do
subject { described_class.new }
let(:domain) { 'obsolete.org' }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ReblogService, type: :service do
RSpec.describe ReblogService do
let(:alice) { Fabricate(:account, username: 'alice') }
context 'when creates a reblog with appropriate visibility' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe RejectFollowService, type: :service do
RSpec.describe RejectFollowService do
subject { described_class.new }
let(:sender) { Fabricate(:account, username: 'alice') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe RemoveFromFollowersService, type: :service do
RSpec.describe RemoveFromFollowersService do
subject { described_class.new }
let(:bob) { Fabricate(:account, username: 'bob') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe RemoveStatusService, :sidekiq_inline, type: :service do
RSpec.describe RemoveStatusService, :sidekiq_inline do
subject { described_class.new }
let!(:alice) { Fabricate(:account) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ReportService, type: :service do
RSpec.describe ReportService do
subject { described_class.new }
let(:source_account) { Fabricate(:account) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe ResolveAccountService, type: :service do
RSpec.describe ResolveAccountService do
subject { described_class.new }
before do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe ResolveURLService, type: :service do
describe ResolveURLService do
subject { described_class.new }
describe '#call' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe SearchService, type: :service do
describe SearchService do
subject { described_class.new }
describe '#call' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe SoftwareUpdateCheckService, type: :service do
RSpec.describe SoftwareUpdateCheckService do
subject { described_class.new }
shared_examples 'when the feature is enabled' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe SuspendAccountService, :sidekiq_inline, type: :service do
RSpec.describe SuspendAccountService, :sidekiq_inline do
shared_examples 'common behavior' do
subject { described_class.new.call(account) }

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe TagSearchService do
describe '#call' do
let!(:one) { Fabricate(:tag, name: 'one') }
before { Fabricate(:tag, name: 'two') }
it 'runs a search for tags' do
results = subject.call('#one', limit: 5)
expect(results)
.to have_attributes(
size: 1,
first: eq(one)
)
end
end
end

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe TranslateStatusService, type: :service do
RSpec.describe TranslateStatusService do
subject(:service) { described_class.new }
let(:status) { Fabricate(:status, text: text, spoiler_text: spoiler_text, language: 'en', preloadable_poll: poll, media_attachments: media_attachments) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe UnallowDomainService, type: :service do
RSpec.describe UnallowDomainService do
subject { described_class.new }
let(:bad_domain) { 'evil.org' }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
describe UnblockDomainService, type: :service do
describe UnblockDomainService do
subject { described_class.new }
describe 'call' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe UnblockService, type: :service do
RSpec.describe UnblockService do
subject { described_class.new }
let(:sender) { Fabricate(:account, username: 'alice') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe UnfollowService, type: :service do
RSpec.describe UnfollowService do
subject { described_class.new }
let(:sender) { Fabricate(:account, username: 'alice') }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe UnsuspendAccountService, type: :service do
RSpec.describe UnsuspendAccountService do
shared_context 'with common context' do
subject { described_class.new.call(account) }

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe UpdateAccountService, type: :service do
RSpec.describe UpdateAccountService do
subject { described_class.new }
describe 'switching form locked to unlocked accounts', :sidekiq_inline do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe UpdateStatusService, type: :service do
RSpec.describe UpdateStatusService do
subject { described_class.new }
context 'when nothing changes' do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe VerifyLinkService, type: :service do
RSpec.describe VerifyLinkService do
subject { described_class.new }
context 'when given a local account' do