Crowdin / Upload translations / upload-translations (push) Skipped
Historical data migration test / test (14-alpine) (push) Canceled after 0s
Historical data migration test / test (15-alpine) (push) Canceled after 0s
Historical data migration test / test (16-alpine) (push) Canceled after 0s
Historical data migration test / test (17-alpine) (push) Canceled after 0s
Bundler Audit / security (push) Canceled after 0s
Haml Linting / lint (push) Canceled after 0s
JavaScript Linting / lint (push) Canceled after 0s
Ruby Linting / lint (push) Canceled after 0s
JavaScript Testing / test (push) Canceled after 0s
Ruby Testing / build (production) (push) Canceled after 0s
Ruby Testing / test (.ruby-version) (push) Canceled after 0s
Ruby Testing / test (3.3) (push) Canceled after 0s
Ruby Testing / test (3.4) (push) Canceled after 0s
Ruby Testing / End to End testing (.ruby-version) (push) Canceled after 0s
Ruby Testing / End to End testing (3.3) (push) Canceled after 0s
Ruby Testing / End to End testing (3.4) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check i18n / check-i18n (push) Canceled after 0s
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (javascript) (push) Canceled after 0s
CodeQL / Analyze (ruby) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Canceled after 0s
Check formatting / lint (push) Canceled after 0s
CSS Linting / lint (push) Canceled after 0s
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Canceled after 0s
Chromatic / Check for relevant changes (push) Canceled after 0s
Chromatic / Run Chromatic (push) Canceled after 0s
Snapshot of upstream tag v4.7.3 (commit 8ff11c2bb7b9f0714e947b10fa3629c6542c7121) from https://github.com/mastodon/mastodon, unmodified.
89 lines
4.0 KiB
Ruby
89 lines
4.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe AccountReachFinder do
|
|
let(:account) { Fabricate(:account) }
|
|
|
|
let(:ap_follower_example_com) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.com/inbox-1', domain: 'example.com') }
|
|
let(:ap_follower_example_org) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.org/inbox-2', domain: 'example.org') }
|
|
let(:ap_follower_with_shared) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/users/a/inbox', domain: 'foo.bar', shared_inbox_url: 'https://foo.bar/inbox') }
|
|
|
|
let(:ap_mentioned_with_shared) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://foo.bar/users/b/inbox', domain: 'foo.bar', shared_inbox_url: 'https://foo.bar/inbox') }
|
|
let(:ap_mentioned_example_com) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.com/inbox-3', domain: 'example.com') }
|
|
let(:ap_mentioned_example_org) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.org/inbox-4', domain: 'example.org') }
|
|
|
|
let(:ap_followed_example_com) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.com/inbox-5', domain: 'example.com') }
|
|
let(:ap_followed_example_org) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.com/inbox-6', domain: 'example.org') }
|
|
|
|
let(:ap_requested_example_com) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.com/inbox-7', domain: 'example.com') }
|
|
let(:ap_requested_example_org) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.com/inbox-8', domain: 'example.org') }
|
|
|
|
let(:unrelated_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.com/unrelated-inbox', domain: 'example.com') }
|
|
let(:old_followed_account) { Fabricate(:account, protocol: :activitypub, inbox_url: 'https://example.com/old-followed-inbox', domain: 'example.com') }
|
|
|
|
before do
|
|
travel_to(2.months.ago) { account.follow!(old_followed_account) }
|
|
|
|
ap_follower_example_com.follow!(account)
|
|
ap_follower_example_org.follow!(account)
|
|
ap_follower_with_shared.follow!(account)
|
|
|
|
account.follow!(ap_followed_example_com)
|
|
account.follow!(ap_followed_example_org)
|
|
|
|
account.request_follow!(ap_requested_example_com)
|
|
account.request_follow!(ap_requested_example_org)
|
|
|
|
Fabricate(:status, account: account).tap do |status|
|
|
status.mentions << Mention.new(account: ap_follower_example_com)
|
|
status.mentions << Mention.new(account: ap_mentioned_with_shared)
|
|
end
|
|
|
|
Fabricate(:status, account: account)
|
|
|
|
Fabricate(:status, account: account).tap do |status|
|
|
status.mentions << Mention.new(account: ap_mentioned_example_com)
|
|
status.mentions << Mention.new(account: ap_mentioned_example_org)
|
|
end
|
|
|
|
Fabricate(:status).tap do |status|
|
|
status.mentions << Mention.new(account: unrelated_account)
|
|
end
|
|
end
|
|
|
|
describe '#inboxes' do
|
|
subject { described_class.new(account).inboxes }
|
|
|
|
it 'includes the preferred inbox URL of followers and recently mentioned accounts but not unrelated users' do
|
|
expect(subject)
|
|
.to include(*follower_inbox_urls)
|
|
.and include(*mentioned_account_inbox_urls)
|
|
.and include(*recently_followed_inbox_urls)
|
|
.and include(*recently_requested_inbox_urls)
|
|
.and not_include(unrelated_account.preferred_inbox_url)
|
|
.and not_include(old_followed_account.preferred_inbox_url)
|
|
end
|
|
|
|
def follower_inbox_urls
|
|
[ap_follower_example_com, ap_follower_example_org, ap_follower_with_shared]
|
|
.map(&:preferred_inbox_url)
|
|
end
|
|
|
|
def mentioned_account_inbox_urls
|
|
[ap_mentioned_with_shared, ap_mentioned_example_com, ap_mentioned_example_org]
|
|
.map(&:preferred_inbox_url)
|
|
end
|
|
|
|
def recently_followed_inbox_urls
|
|
[ap_followed_example_com, ap_followed_example_org]
|
|
.map(&:preferred_inbox_url)
|
|
end
|
|
|
|
def recently_requested_inbox_urls
|
|
[ap_requested_example_com, ap_requested_example_org]
|
|
.map(&:preferred_inbox_url)
|
|
end
|
|
end
|
|
end
|