mastodon/spec/models/remote_follow_spec.rb
Claire 264d068d8d
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
Chromatic / Run Chromatic (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Change new accounts to use new ActivityPub numeric ID scheme (#36365)
2025-10-14 16:36:55 +00:00

77 lines
1.7 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe RemoteFollow do
before do
stub_request(:get, 'https://quitter.no/.well-known/webfinger?resource=acct:gargron@quitter.no').to_return(request_fixture('webfinger.txt'))
end
let(:attrs) { nil }
let(:remote_follow) { described_class.new(attrs) }
describe '.initialize' do
subject { remote_follow.acct }
context 'when attrs with acct' do
let(:attrs) { { acct: 'gargron@quitter.no' } }
it 'returns acct' do
expect(subject).to eq 'gargron@quitter.no'
end
end
context 'when attrs without acct' do
let(:attrs) { {} }
it do
expect(subject).to be_nil
end
end
end
describe '#valid?' do
subject { remote_follow.valid? }
context 'when attrs with acct' do
let(:attrs) { { acct: 'gargron@quitter.no' } }
it do
expect(subject).to be true
end
end
context 'when attrs without acct' do
let(:attrs) { {} }
it do
expect(subject).to be false
end
end
end
describe '#subscribe_address_for' do
subject { remote_follow.subscribe_address_for(account) }
before do
remote_follow.valid?
end
let(:attrs) { { acct: 'gargron@quitter.no' } }
let(:account) { Fabricate(:account, username: 'alice') }
it 'returns subscribe address' do
expect(subject).to eq(expected_subscribe_url)
end
def expected_subscribe_url
Addressable::URI.new(
host: 'quitter.no',
path: '/main/ostatussub',
query_values: { profile: ActivityPub::TagManager.instance.uri_for(account) },
scheme: 'https'
).to_s
end
end
end